Connecting Tech Pros Worldwide Help | Site Map

get query values but do not show them

Newbie
 
Join Date: Sep 2009
Posts: 18
#1: Sep 29 '09
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>
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,094
#2: Sep 29 '09

re: get query values but do not show them


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
Newbie
 
Join Date: Sep 2009
Posts: 18
#3: Sep 29 '09

re: get query values but do not show them


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
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#4: Sep 29 '09

re: get query values but do not show them


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