Jump to content

getting query values into text box, then pass them to another page


jjmusicpro

Recommended Posts

just curious, how do i get the values from a query from a db into text box's, in a form, so i can hit submit and it goes to an "update" page?

 

<?php

if (isset($_POST['update'])){

   echo "<p>Error, please try again";

} else {

require_once ('connect.php'); 
require_once ('opendb.php');  
$groupid_sent = $_GET['groupid'];	
$query = "SELECT * FROM zipcodes WHERE search_id='$zip_id'"; 
$result = @mysql_query ($query); 
$count = mysql_num_rows($result); //number of results 
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ 
$groupid_sent= $row['account_name'] ;
$account_name= $row['company_name'] ;
$zip_id = $row['search_id'] ;
$zipcode = $row['zipcode'];
echo "Edit Zip Code <b>$zipcode</b> for $account_name";
echo "<form>";
echo "test data";
echo "</form>";
}

}

  • 1 year later...

this is how you would do it if you are writing the form within the php tags

echo "<form>";
echo "<input type='text' name='groupid' value='".$groupid_sent."'>";
echo "<input type='text' name='account_name' value='".$account_name."'>";
echo "<input type='text' name='zipid' value='".$zip_id."'>";
echo "<input type='text' name='zipcode' value='".$zipcode."'>";
echo "</form>";

 

if you decide to close the tags after this line:

echo "Edit Zip Code <b>$zipcode</b> for $account_name";

you will need to do this:

echo "Edit Zip Code <b>$zipcode</b> for $account_name";
?>
<form>
<input type="text" name="groupid" value="<? echo $groupid_sent; ?>">
<input type="text" name="account_name" value="<? echo $account_name; ?>">
<input type="text" name="zipid" value="<? echo $zip_id; ?>">
<input type="text" name="zipcode" value="<? echo $zipcode; ?>">
</form>
<? // rest of php code....

 

hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.