Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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