jjmusicpro Posted October 2, 2007 Share Posted October 2, 2007 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>"; } } Link to comment https://forums.phpfreaks.com/topic/71524-getting-query-values-into-text-box-then-pass-them-to-another-page/ Share on other sites More sharing options...
thunder708 Posted August 12, 2009 Share Posted August 12, 2009 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 Link to comment https://forums.phpfreaks.com/topic/71524-getting-query-values-into-text-box-then-pass-them-to-another-page/#findComment-896248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.