Hi,
I wonder if anyone can help me. I use a loop on my site to bring up some results but I need to find a way to ending the loop if it finds any results.
I use the following code:
$sql = "SELECT * FROM `people` WHERE `people_id` = '$people_id' ";
$result1 = mysql_query($sql);
while ( $myrow = mysql_fetch_array($result1) ) {
$people_name = $myrow["people_name"];
for ($loop=0;$loop<10;$loop++) {
$director = ($loop>0 ? $loop : '');
$query = "SELECT * FROM `castcrew` WHERE `starring$director` = '$people_id' LIMIT 1";
$results = mysql_query($query) or die ('Unable to query database for peoplenames');
while ( $row = mysql_fetch_array($results) ) {
$prog_id = $row['prog_id'];
echo("<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td class=\"bodyBlack\">$people_name appeared in: </td>
</tr>
<tr>
<td><img src=\"../Forums/line.gif\" width=\"391\" height=\"1\"></td>
</tr>
</table><br>");
} // ends while loop
}
}
It creates a little header, but will create as many headers as results if they are in different collums in my database. I.e it will search for the people_id number in fields starring , starring1 , starring2 , etc all the way to starring9.
If the people id is in starring and starring2 for example it will display two headers.
What I want is for it to stop displaying headers after it has found one, i.e ending the loop.
I'm sure this most be possible, any help will be most appreciated.
Thanks.