By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

display multiple rows in a form

P: 18
Hello, I am trying to retrieve multiple rows from a database, place each row into a form and beside each row add an input field with a variable field name.

So far I can only pull one row.

If it helps to conceptualize, I am pulling an inventory db (vendor, item#, description, etc) I want to return each item line by line and beside each item provide a space to input the quantity the client would like to order...

So far I have the following:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. @mysql_connect("localhost","onlineapp","XXXXXX");
  3. if (!@mysql_connect)
  4.   {
  5.   die('Could not connect: ' . mysql_error());
  6.   }
  7. mysql_select_db("inventory");
  8. ?>
  9. <form action="abadult_walkin_form.php" method="post" name="walkin_form" align="left" class="style3" bgcolor="#ffffff" onSubmit="return verifyForm(this);">
  10.  <fieldset>
  11. <legend>INVENTORYMASTER</legend>
  12. <table class="mainmenu" border="0" cellpadding="0" cellspacing="0">
  13. <?php
  14. $sql = "SELECT * FROM test2";
  15. $query = mysql_query($sql) ;
  16. while($row = mysql_fetch_array($query)) {
  17. $id=null;
  18. $id=$row['id']; 
  19. $Vendor=null;
  20. $Vendor=$row['Vendor'];
  21. $description=null;
  22. $description=$row['description'];
  23. $item_no=null;
  24. $item_no=$row['item_no'];
  25. }
  26. mysql_close()
  27. ?>
  28. <tr class="style1">
  29.  <td align="center"> &nbsp; &nbsp; &nbsp;
  30.  <?php echo "$id";?>
  31.  </td>
  32.  <td align="center"> &nbsp; &nbsp; &nbsp;
  33.  <?php echo "$Vendor";?>
  34.  </td>
  35.  <td align="center"> &nbsp; &nbsp; &nbsp;
  36.  <?php echo "$description";?>
  37.  </td>
  38.  <td align="center"> &nbsp; &nbsp; &nbsp;
  39.  <?php echo "$item_no";?>
  40.  </td>
  41.  </tr> 
  42.  
  43. </table>
  44. </form>
Sep 21 '09 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
@monion
let me guess, itís the last row?

you have to put the output code into the loop, too.
Sep 21 '09 #2

P: 18
It is, how do I do this?
Sep 21 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
move lines 25-27 to the end, without violating the syntax.
Sep 21 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.