Page 2 of 2

Re: subresult

Posted: Sat Feb 02, 2008 5:57 pm
by califdon
dramiditis wrote:Hi,
I try with "LIMIT" in the SQL query, but then the script is dead. I have alredy set limit to 5 at the beggining of the script, but when the results is displayed ( with more than 5 ) and I pres "NEXT " it does't goes to the rest of results, but only refresh the same page.
I'm testing this script on one free hosting site, so you can see it:

http://www.videoworld.fancyfreehosting. ... mit=Search

Regards
The reason it doesn't go to other pages is what I explained to you: you are not using LIMIT in your query. It always asks for all the records to be returned, and since you only display the first 5, that is precisely what you see.

In order to learn how to make your query do what it needs to do, I suggest you create a test script that does nothing but query the database and display what it returns. Having pages of code makes it very difficult to understand what is going wrong. Open a new file test.php and enter the following:

Code: Select all

<html>
<body>
<?php
include("db.php");
$query="SELECT * FROM video LIMIT 4";
$result = mysql_query($query) or die("Couldn't execute query");
while ($row=mysql_fetch_array($result)) {
    foreach($row as $field) {
        echo "$field -- ";
    }
    echo "<br />";
}
?>
</body>
</html>
 
Upload it and run it by entering ".../test.php" in your browser, and see what you get. Then change the $query line to say:

Code: Select all

$query="SELECT * FROM video LIMIT 3,4";
and notice that you are seeing different records than before.

Even better, read http://php.about.com/od/mysqlcommands/g/Limit_sql.htm and http://www.developerfusion.co.uk/show/3998/7/ to learn how LIMIT works in a SQL statement.

Re: subresult

Posted: Fri Feb 22, 2008 2:22 pm
by dramiditis
Hi califdon,
I have finally finished my script and you can check my website at http://www.wudar.com if
you have any comment or suggestion pls write.
Regards
Dragan

Re: subresult

Posted: Fri Feb 22, 2008 3:04 pm
by califdon
Your new site looks very attractive. I'm glad that you got the queries working properly. Good luck.

Re: subresult

Posted: Fri Feb 22, 2008 3:06 pm
by dramiditis
Thank you for all your support and help when I had problems.
Regards