matt2kjones
11-04-2002, 01:45 PM
ok then, i have built a webhost search script which searches through a mysql database, and displays the results on a page.
The user selects what they want, i.e ftp, 200MB space, php, mysql etc etc.
well i got the script to display the data but i have a problem
If the script finds more than 20 webhosts, the script will stop, which is what i want. But if the script doesn't find 20 hosts, it will just keep on looping and looping.
I need to know a way so that if the script comes to the end of all the rows in a database, the script stops.
here is the code that i have done :
$stop = no;
$max_results = 0;
$hostid = 1;
while ($stop == no)
{
$my_query = "SELECT hostid, webhost_link, webhost_description FROM webhosts WHERE (
hostid = '$hostid' && ftp = '$ftp' && mysql = '$mysql' && pre_installed_scripts =
'$pre_scripts' && email = '$email' && browser_upload = '$browser_upload' &&
show_cobrands = '$show_cobrands' && php = '$php' && cgi_bin = '$cgi_bin' &&
sub_domain = '$subdomain' && domain_hosting = '$domain_hosting')";
$result = mysql_query($my_query);
$data = mysql_fetch_array($result);
$webhost_link = $data['webhost_link'];
$webhost_description = $data['webhost_description'];
$host_id = $data['hostid'];
if($webhost_link != "")
{
echo ($webhost_name);
echo ('<BR>');
echo ($webhost_link);
echo ('<BR>');
echo ($webhost_description);
echo ('<BR>');
echo ($host_id);
echo ('<BR><BR>');
$max_results ++;
}
if($max_results == 21)
{
$stop == yes;
}
$hostid ++;
}
so what i need is a way so that i can do this :
if(i get to the last row in the table)
{
$stop == yes;
echo ("No more Results");
}
how could i do this???
i need to know once i have gone through all the rows in a table and have come to the end.
Thanx
The user selects what they want, i.e ftp, 200MB space, php, mysql etc etc.
well i got the script to display the data but i have a problem
If the script finds more than 20 webhosts, the script will stop, which is what i want. But if the script doesn't find 20 hosts, it will just keep on looping and looping.
I need to know a way so that if the script comes to the end of all the rows in a database, the script stops.
here is the code that i have done :
$stop = no;
$max_results = 0;
$hostid = 1;
while ($stop == no)
{
$my_query = "SELECT hostid, webhost_link, webhost_description FROM webhosts WHERE (
hostid = '$hostid' && ftp = '$ftp' && mysql = '$mysql' && pre_installed_scripts =
'$pre_scripts' && email = '$email' && browser_upload = '$browser_upload' &&
show_cobrands = '$show_cobrands' && php = '$php' && cgi_bin = '$cgi_bin' &&
sub_domain = '$subdomain' && domain_hosting = '$domain_hosting')";
$result = mysql_query($my_query);
$data = mysql_fetch_array($result);
$webhost_link = $data['webhost_link'];
$webhost_description = $data['webhost_description'];
$host_id = $data['hostid'];
if($webhost_link != "")
{
echo ($webhost_name);
echo ('<BR>');
echo ($webhost_link);
echo ('<BR>');
echo ($webhost_description);
echo ('<BR>');
echo ($host_id);
echo ('<BR><BR>');
$max_results ++;
}
if($max_results == 21)
{
$stop == yes;
}
$hostid ++;
}
so what i need is a way so that i can do this :
if(i get to the last row in the table)
{
$stop == yes;
echo ("No more Results");
}
how could i do this???
i need to know once i have gone through all the rows in a table and have come to the end.
Thanx
