Jump to content

Recommended Posts

Hi

I 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 10

this 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);

?>
Link to comment
https://forums.phpfreaks.com/topic/15161-mysql_data_seek/
Share on other sites

[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.

Thanks

Scott
Link to comment
https://forums.phpfreaks.com/topic/15161-mysql_data_seek/#findComment-61155
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.