stb74 Posted July 20, 2006 Share Posted July 20, 2006 HiI have a piece of code that runs through a loop to display 15 drop down lists to select teams for matches in a soccerstats program. But I keep getting this error.Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index 10this is the code <?php // //Query to get the teams from selected divisions. // $get_teams = mysql_query(" SELECT teamID AS id, teamName AS name FROM test_teams WHERE teamdivisionID = '$divisionid' ORDER BY teamName ", $connection) or die(mysql_error()); // //Prints 15 forms // $i=0; while($i < 15) { // //Query back to row 0 if not the first time in the loop // if($i > 1) mysql_data_seek($get_teams, 0); echo' <tr> <td align="left" valign="middle"> '; echo"<select name=\"home[$i]\">"; while($data = mysql_fetch_array($get_teams)) { echo"<option value=\"$data[id]\">$data[name]</option>\n"; } echo' </select> </td> <td align="left" valign="middle"> '; // //Back to line 0 in the query // mysql_data_seek($get_teams, 0); echo"<select name=\"away[$i]\">"; while($data = mysql_fetch_array($get_teams)) { echo"<option value=\"$data[id]\">$data[name]</option>\n"; } echo" </select> </td> <td align=\"center\" valign=\"middle\"><input type=\"text\" name=\"home_goals[$i]\" size=\"2\"></td> <td align=\"center\" valign=\"middle\"><input type=\"text\" name=\"away_goals[$i]\" size=\"2\"></td> </tr> "; $i++; } mysql_free_result($get_teams); ?> Quote Link to comment https://forums.phpfreaks.com/topic/15161-mysql_data_seek/ Share on other sites More sharing options...
trq Posted July 20, 2006 Share Posted July 20, 2006 Your going abou this completely the wrong way. Look into using a LIMIT clause in your query, then simply loop through a while() until all results have been displayed. Quote Link to comment https://forums.phpfreaks.com/topic/15161-mysql_data_seek/#findComment-61075 Share on other sites More sharing options...
stb74 Posted July 20, 2006 Author Share Posted July 20, 2006 [quote author=thorpe link=topic=101262.msg400501#msg400501 date=1153410009]Your going abou this completely the wrong way. Look into using a LIMIT clause in your query, then simply loop through a while() until all results have been displayed.[/quote]I am a complete novice and I am learning as I go.This is someone else's code that I am trying to tidy up and improve on, they aren't available to help anymore. If you can give a couple of pointers as to what you mean I would appreciate it.ThanksScott Quote Link to comment https://forums.phpfreaks.com/topic/15161-mysql_data_seek/#findComment-61155 Share on other sites More sharing options...
treilad Posted July 20, 2006 Share Posted July 20, 2006 http://pear.php.net/manual/en/html/package.database.db-dataobject.db-dataobject.limit.html Quote Link to comment https://forums.phpfreaks.com/topic/15161-mysql_data_seek/#findComment-61160 Share on other sites More sharing options...
stb74 Posted July 20, 2006 Author Share Posted July 20, 2006 Can't access that. Quote Link to comment https://forums.phpfreaks.com/topic/15161-mysql_data_seek/#findComment-61169 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.