468,458 Members | 1,777 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

get query values but do not show them

18
One more question.
How can I get query values assign them to a variable, but not show them?
for example size, $f4 in the following: How can I pass that value $f4 to the form handle page to submit to the database. I can clearly see how to pass $f2 with quantity stuck on the end.

Basically, I need to pass 3 things: 1) item#, 2) item#quantity and 3) size to a new database.



Expand|Select|Wrap|Line Numbers
  1. mysql_select_db("inventory");
  2. $query="SELECT * FROM pecialtymaster where Dental='Y'";
  3. $result=mysql_query($query);
  4. $num=mysql_numrows($result);
  5. mysql_close();
  6. ?>
  7.  
  8. <form action="inventorymaster_form.php" method="post"
  9. name="inventorymaster_form" align="left" class="style3" bgcolor="#ffffff"
  10. onSubmit="return verifyForm(this);">
  11.  
  12. <table border="1" class="mainmenu" border="0" cellpadding="0"
  13. cellspacing="0">
  14. <?php
  15. echo "<table border='1'>
  16. <tr>
  17. <th>Item #</th>
  18. <th>Item Description</th>
  19. <th>Size</th>
  20. <th>Distribution Quantity</th>
  21. <th>Current Quantity</th>
  22. </tr>";
  23. ?>
  24. <?php
  25. $i=0;
  26. while ($i<$num) {
  27. $f2=mysql_result($result,$i,"item_number");
  28. $f3=mysql_result($result,$i,"item");
  29. $f4=mysql_result($result,$i,"size");
  30. $f5=mysql_result($result,$i,"distquantity");
  31. ?>
  32.  
  33. <tr>
  34. <td> &nbsp &nbsp <?php echo $f2;?>&nbsp &nbsp </td>
  35. <td> &nbsp &nbsp <?php echo $f3;?>&nbsp &nbsp </td>
  36.  
  37.  
  38. <td> &nbsp &nbsp <?php echo $f5;?>&nbsp &nbsp </td>
  39. <td align="center"> <input type='text' name="<?php echo $f2?>quantity"
  40. value="" onkeypress="return noenter()">
  41.  
  42. </tr>
  43. <?php
  44. $i++;
  45. }
  46. ?>
  47. </table>
Sep 29 '09 #1
3 2478
dlite922
1,584 Expert 1GB
Don't show them? so don't echo them.

If the other database is on the same host, you can even move the values via SQL. Else just while loop them like you have for the display but do an insert.



Dan
Sep 29 '09 #2
monion
18
Maybe I'm missing something. The preceding is part of a form. I want to import some values from 1 database table and pass them to a seperate one. The only way I know is to perform an <input...name=...> How can I also assign a name to a $variable? I'm new with PHP and mysql so please be patient.

Thanks,
MO
Sep 29 '09 #3
Dormilich
8,651 Expert Mod 8TB
you don't need a form for that. the job can be done on the server. basicly you do
Expand|Select|Wrap|Line Numbers
  1. // not real code
  2. R1 = connect MySQL-1
  3. R2 = connect MySQL-2
  4. R1 : SELECT ... FROM ...
  5. R2 : INSERT INTO ... VALUES R1
case 1: both database tables are on the same host, this can be done using a single SQL querz (as dlite mentioned)
case 2: there is a lot of code out there that can make this very easy to code. but this code is not as easy to understand as the standard PHP MySQL-functions.
Sep 29 '09 #4

Post your reply

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

Similar topics

4 posts views Thread by Orion | last post: by
9 posts views Thread by Mark | last post: by
4 posts views Thread by Joe-Paul | last post: by
12 posts views Thread by Tom | last post: by
4 posts views Thread by John | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.