dm_mcelduff
asked on
Passing variables between pages
Hi,
I am using the code below to display a table on a page with some information for a helpdesk. I want the user to have the ability to look at more detailed information on the incident by clicking the incident number. The link to the other page works using the code :
echo '<td> <a href="details.php">'.$row[ 'incidentn o'].'</a>< /td>'; (for full code listing see below)
This link works but on the 'details.php' page I only want to show details of the incident selected by the user. I know that I need to pass a variable to the other page but how?
PHP code used on page:
<?php
mysql_connect("localhost", "administrator", "password");
echo '<table width="85%" border="1">';
echo '<tr><th>Incident Number</th><th>Type</th><t h>Decripti on</th><th >Date</th> <th>Engine er</th></t r>';
$sql="SELECT incidentno, type, shortdesc, date, engineer FROM helpdesk.incidents WHERE status = 'Open'";
$result=mysql_query($sql);
if(mysql_num_rows($result) >0)
{
while($row=mysql_fetch_ass oc($result ))
{
echo '<tr>';
echo '<td> <a href="details.php">'.$row[ 'incidentn o'].'</a>< /td>';
echo '<td>'.$row['type'].'</td> ';
echo '<td>'.$row['shortdesc'].' </td>';
echo '<td>'.$row['date'].'</td> ';
echo '<td>'.$row['engineer'].'< /td>';
echo '</tr>';
}
}
else
{
echo '<tr><td colspan="200">no data retieved</td></tr>';
}
echo '</table>';
?>
I am using the code below to display a table on a page with some information for a helpdesk. I want the user to have the ability to look at more detailed information on the incident by clicking the incident number. The link to the other page works using the code :
echo '<td> <a href="details.php">'.$row[
This link works but on the 'details.php' page I only want to show details of the incident selected by the user. I know that I need to pass a variable to the other page but how?
PHP code used on page:
<?php
mysql_connect("localhost",
echo '<table width="85%" border="1">';
echo '<tr><th>Incident Number</th><th>Type</th><t
$sql="SELECT incidentno, type, shortdesc, date, engineer FROM helpdesk.incidents WHERE status = 'Open'";
$result=mysql_query($sql);
if(mysql_num_rows($result)
{
while($row=mysql_fetch_ass
{
echo '<tr>';
echo '<td> <a href="details.php">'.$row[
echo '<td>'.$row['type'].'</td>
echo '<td>'.$row['shortdesc'].'
echo '<td>'.$row['date'].'</td>
echo '<td>'.$row['engineer'].'<
echo '</tr>';
}
}
else
{
echo '<tr><td colspan="200">no data retieved</td></tr>';
}
echo '</table>';
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers cLFlaVA that worked a treat :)
<a href="mypage.php?VariableN
To add more than one variable to pass simply use the & symbol. For example:
<a href="mypage.php?name=$use
You can pass as many variables as you need to. To access the variable value in the following php page simply refer to it as the VariableName (as in my first example). Or in my second example:
echo "Hello there ".$name." welcome to my new page!";
Hope this helps. Cheers.
Jayce