brooksh Posted June 20, 2007 Share Posted June 20, 2007 Can someone tell me why I'm only getting 1 result back? $sql = "SELECT id,mls,imagename FROM images"; $result = mysql_query ($sql); while($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { $id = $row[id]; $mls = $row[mls]; $imagename = $row[imagename]; $sql = "SELECT id FROM residential WHERE mls = '$mls'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==0){ mysql_query("DELETE FROM images WHERE mls = '$mls'"); $path = "/home/endtek/public_html/images/mlsimages/imls/$imagename"; if (file_exists($path)) { unlink($path); } }//end count=0 }//end while Link to comment https://forums.phpfreaks.com/topic/56431-solved-why-am-i-only-getting-one-result-back-instead-of-many/ Share on other sites More sharing options...
akitchin Posted June 20, 2007 Share Posted June 20, 2007 it's because you're replacing the $result resource that you're looping on, within the loop. rename your $result variable within the while() loop and you'll be able to process the entire resultset. Link to comment https://forums.phpfreaks.com/topic/56431-solved-why-am-i-only-getting-one-result-back-instead-of-many/#findComment-278699 Share on other sites More sharing options...
brooksh Posted June 20, 2007 Author Share Posted June 20, 2007 Of course. Thanks so much. Sometimes I overlook the easiest things. Link to comment https://forums.phpfreaks.com/topic/56431-solved-why-am-i-only-getting-one-result-back-instead-of-many/#findComment-278701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.