Re: Why doesn't the second instance work?

From: Date: Tue, 03 Sep 2002 01:38:14 +0000
Subject: Re: Why doesn't the second instance work?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114967@lists.php.net to get a copy of this message
Hi, Tuesday, September 3, 2002, 6:49:25 AM, you wrote: MK> Everything is good, Everything is fine, so I decide to put the same=20 MK> snippet of code in again, this time pointing to a different page -- MK> One=20= MK> page lets you edit the fields, the other shows you the final output,=20 MK> the item from the database featured on a web page. MK> <p>preview an endpage:</p> MK> <? MK> //create a list of editible items MK> echo "<form method=3Dpost action=3Dpreview.php>"; MK> echo "<select name=3Did>"; MK> for ($i=3D0; $i <$num_results; $i++) MK> { MK> $row =3D mysql_fetch_array($result); MK> echo "<option value=3D$row[id]> $row[id], = MK> $row[productname]</option>"; MK> } MK> echo "</select>"; MK> echo "<input type=3Dsubmit name=3Dsubmit>"; MK> echo "</form>"; ?>>=00=00 MK> The second instance does not work, I get a select with "," as each=20 MK> option, no population with the id or productname. Clearly, I don't=20 MK> understand something here, can anyone tell me what? MK> Thanks for the time, MK> Michael To use the result a second time you will need to reset the internal mysql pointer like this: mysql_data_seek($result,0); After the first loop through. -- regards, Tom

« previous php.general (#114967) next »