wrathican Posted May 15, 2008 Share Posted May 15, 2008 hey guys. i have a script that contains a dropdown list that is populated by querying a DB. The only problem is the list is missing out the first entry in the table. no matter whether or not it is the actual first entry with an id of 1 or its the 50th with and id of 50 and all of records 1-49 have been deleted it still would not show. any ideas why this is happening? heres my script(it's not all of because most of it is irrelevant, and yes i have started the session ): <?php $userid = $_SESSION['userid']; $query = "SELECT album_id, album_name FROM ls12_album WHERE album_ownerid='".$userid."'"; $result = mysql_query($query); $array = fetchArray($result); $numRows = mysql_num_rows($result); if($numRows == 0){ echo "Sorry, but none of the albums belong to you. Please create an album."; }else{ echo $userid; ?> <form action="../functions/memberfunctions.php?func=addimage" method="post" enctype="multipart/form-data" name="frmAlbum" id="frmAlbum" class="form"> Add To Album:<br /> <?php echo '<select name="albumId">'; while ($row = mysql_fetch_assoc($result)+1) { //declare vars $albumid = $row['album_id']; $albumtitle = $row['album_name']; echo '<option value="'.$albumid.'">'.$albumtitle.'</option>'; } echo "</select>"; ?> <br /> Image Title:<br /> <input name="imgName" type="text" id="txtName"><br /> Description:<br /> <textarea name="imgDesc" cols="50" rows="4" id="mtxDesc"></textarea><br /> Image:<br /> <input name="fileImage" type="file" class="box" id="fleImage"><br /> <input name="btnAdd" type="submit" id="btnAdd" value="Add Image"> <input name="btnCancel" type="button" id="btnCancel" value="Cancel" onClick="window.history.back();"> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/105738-solved-while-loop-missing-first-entry-in-db/ Share on other sites More sharing options...
kenrbnsn Posted May 15, 2008 Share Posted May 15, 2008 You have <?php $array = fetchArray($result); ?> before your loop, which, while I don't know what it does, is probably getting the first record. Ken Link to comment https://forums.phpfreaks.com/topic/105738-solved-while-loop-missing-first-entry-in-db/#findComment-541780 Share on other sites More sharing options...
wrathican Posted May 15, 2008 Author Share Posted May 15, 2008 Argh! Thank you so much. i had been over thinking it. silly me. Thanks for that! Link to comment https://forums.phpfreaks.com/topic/105738-solved-while-loop-missing-first-entry-in-db/#findComment-541884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.