ainoy31 Posted December 21, 2007 Share Posted December 21, 2007 Hello- I am passing a variable in the URL to another page. <? echo "<a href='quote_transaction.php?id=$q[quote_id]&action=Edit'>Edit</a>" ?> On the second page I need to be able to retrieve all the data for that ID. I am going to display all the information and give the option to edit each input field. This is where my problem is. I have tried doing the following: $action = $_GET['action']; $id = $_GET['id']; if(isset($action)) { switch($action) { case 'Edit': $sql = "SELECT * FROM intl_quote WHERE quote_id = '$id'"; $result = pg_query("$sql"); if(!sql) { die("Error in SQL query: " . pg_last_error()); } if(pg_num_rows($result)) { while($q = pg_fetch_array($result)) { <div class="formitem"> <table> <tr> <td>Anticipated Ship Date:</td> <td><input type="text" name="ship_date" value="$q[ship_date]" class="datepicker" /></td> </tr> <tr> <td>Company Name:</td> <td><input type="text" name="company_name" value="$q[company_name]" size="20"/></td> </tr> <tr> <td>Contact Person:</td> <td><input type="text" name="company_contact" value="$q[company_contact]" size="20"/></td> </tr> </table </div> } } } } In the input field, I get $q[ship_date] instead of the actually value. Much appreciation. AM Link to comment https://forums.phpfreaks.com/topic/82750-solved-request-a-variable/ Share on other sites More sharing options...
papaface Posted December 21, 2007 Share Posted December 21, 2007 Pretty sure <? echo "<a href='quote_transaction.php?id=$q[quote_id]&action=Edit'>Edit</a>" ?> should be: <? echo "<a href='quote_transaction.php?id=$q['quote_id']&action=Edit'>Edit</a>" ?> Link to comment https://forums.phpfreaks.com/topic/82750-solved-request-a-variable/#findComment-420877 Share on other sites More sharing options...
PHP_PhREEEk Posted December 21, 2007 Share Posted December 21, 2007 If that doesn't work, try: <? echo "<a href='quote_transaction.php?id={$q['quote_id']}&action=Edit'>Edit</a>" ?> Also, when sending URLs to the browser with & in them, use & <? echo "<a href='quote_transaction.php?id={$q['quote_id']}&action=Edit'>Edit</a>" ?> PhREEEk Link to comment https://forums.phpfreaks.com/topic/82750-solved-request-a-variable/#findComment-420880 Share on other sites More sharing options...
ainoy31 Posted December 21, 2007 Author Share Posted December 21, 2007 Thanks for all the advice but that is not the case. I am able to echo $q[ship_date] on the second page and it reads out the correct date. Link to comment https://forums.phpfreaks.com/topic/82750-solved-request-a-variable/#findComment-420882 Share on other sites More sharing options...
ainoy31 Posted December 21, 2007 Author Share Posted December 21, 2007 I figured it out. The solution is to do the following: <td>Anticipated Ship Date:</td> <td><input type="text" name="ship_date" value="<? echo $q[ship_date]; ?>" /></td> Thanks guys. I overlooked something easy. Been coding too much lately with deadline approaching... Link to comment https://forums.phpfreaks.com/topic/82750-solved-request-a-variable/#findComment-420885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.