gerkintrigg Posted April 21, 2006 Share Posted April 21, 2006 Hi all.I'm trying to loop through an SQL array (something I've done numerous times before) but this time it's retrieving all but one of the results...here's the code I'm using:[code]<?php $sql = mysql_query("SELECT * FROM scenes LIMIT 9999"); $p = mysql_fetch_array($sql);?> <select name="select" class="search"> <?php while ($p = mysql_fetch_array($sql)){ echo '<option value="'.$p['scene_number'].'">Scene '.$p['scene_number'].' - Containing '.$p['no_of_shots'].' Shots</option>'; } ?>[/code]It's for a database of shots and can be found at [a href=\"http://www.magic2k.com/422/search/\" target=\"_blank\"]My development page[/a]I've been staring at it for too long perhaps.If anyone can help or suggest anything that could sort the problem that'd be great. Many thanks. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 21, 2006 Share Posted April 21, 2006 Started reading the code, first thing i thought of as i read it... Are there 10000 entries in the table? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 21, 2006 Share Posted April 21, 2006 You're retrieiving the first record, doing nothing with it and then retrieving the rest. Remove the first msql_fetch...[code]<?php$sql = mysql_query("SELECT * FROM scenes LIMIT 9999");echo '<select name="select" class="search">';while ($p = mysql_fetch_array($sql)) echo '<option value="'.$p['scene_number'].'">Scene '.$p['scene_number'].' - Containing '.$p['no_of_shots'].' Shots</option>';?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.