Jump to content

Recommended Posts

Have a web page that displays a number of update forms depending on the amout of records that get returned from a mysql query, if query returns 4 records then the page will display 4 identical forms, the trouble i'm having is getting the each  of the 4 forms to display a different record as at the moment they all show just first record of query.

 

I have played around with loops but not getting anywhere which may be due to my limited knowledge code for page is below

 

 <?php $numberofrow =mysql_num_rows($Recordset1);

for($counter = 1;$counter<=$numberofrow;$counter++){ 
?>
  <label for="hometeam2"></label>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  <label for="hometeam"></label>


  
  <input name="fixid" type="text" id="fixid" value="<?php echo $row_Recordset1['FixtureID']; ?>" />
  <input name="hometeam" type="text" id="hometeam2" value="<?php echo $row_Recordset1['hometeamname']; ?>" />
  <label for="homescore"></label>
  <input name="homescore" type="text" id="homescore" value="<?php echo $row_Recordset1['homescore']; ?>" />
  <label for="awayscore"></label>
  <label for="fixid"></label>
  <input name="awayscore" type="text" id="awayscore" value="<?php echo $row_Recordset1['awayscore']; ?>" />
<label for="awayteam"></label>
<input name="awayteam" type="text" id="awayteam" value="<?php echo $row_Recordset1['awayteamname']; ?>" />
<input type="submit" name="update" id="update" value="Submit" />
<input type="hidden" name="MM_update" value="form1" />

:D  thank you it works 95%, only problem is it misses out first record,  if query returns 4 it will still show 4 forms but only 3 records leaving 1 form blank

 

kenny

 

Edit: :D :D :D

code now working 100% had to remove

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

from after select query as that was 1st record and was getting lost

 

Many thanks again

It sounds like you're calling mysql_fetch_array(), or whichever fetch you're using, once before you enter a while loop, but since you didn't post that part of the code, it's kind of hard to be sure.

It sounds like you're calling mysql_fetch_array(), or whichever fetch you're using, once before you enter a while loop, but since you didn't post that part of the code, it's kind of hard to be sure.

 

correct was calling  mysql_fetch_array()  before loop,  see my post above as i've edited it

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.