Looping results problem

From: Date: Thu, 01 May 2003 12:47:07 +0000
Subject: Looping results problem
Groups: php.general 
Request: Send a blank email to php-general+get-145936@lists.php.net to get a copy of this message
Hi, I have the following code in my page to fill a list menu with page titles and id numbers form a database query: //insert form with a list menu echo "<form name=\"parent\" method=\"post\" action=\"2.php\">\n"; echo "<select name=\"pageParent\" id=\"pageParent\">\n"; $qry = "SELECT pageID,pageTitle from tblContent where pageChild = 0"; $qryResult = mysql_query($qry,$conn); $num_results = mysql_num_rows($qryResult); for ($i=0; $i<$num_results; $i++){ $row = mysql_fetch_row($qryResult,$i); echo "<option value=\""; echo $row['pageID']; echo "\">"; echo $row['pageTitle']; echo "</option>\n"; } echo "</select>\n"; echo "<input type=\"submit\" name=\"submit\" value=\"Continue>>\" />\n"; echo "</form>\n"; When the page is displayed though, only every other <option> tag is completed. Below is the code when I view>source the page: <select name="pageParent" id="pageParent"> <option value=""></option> <option value="2">Links</option> <option value=""></option> <option value="4">Project Summary</option> <option value=""></option> <option value="6">Similar Projects</option> <option value=""></option> </select> This really has me baffled because the number of records is correct (there should be 7 records). Why is it only showing alternate? Thanks, Matt

« previous php.general (#145936) next »