Jump to content

Problem with Hyperlink


takeiteasy

Recommended Posts

In my index page, i have this hyperlink on the employer name which i clicked and it will bring me to a new form whereby it will display the specifc employer's detailed information. But i can't figure out the code for interacting the index page and the more detailed page.

here is my code in the index page.
[code]
if ($custLoan OR $compLoan !='0') {
    echo "<tr>
   <td width='20' bgcolor='$row_color' nowrap>
    <input type='checkbox' name='empRef' value='$empRef'>
   </td>
    <td width='60' bgcolor='$row_color' nowrap>
    $empRef
   </td>
    <td width ='120' bgcolor='$row_color'>
    [color=#FF6666]<a href=\"display.php?pid=$row[empRef]\"> $empName </a>[/color]
   </td>
    <td width ='120' bgcolor='$row_color'>
     $workerName
   </td>
   <td width ='80' bgcolor='$row_color'>
     $AD
   </td>
    <td bgcolor='$row_color'>
     $$custLoan
    </td>
   <td bgcolor='$row_color'>
     $$compLoan
    </td>
    </tr>"; [/code]

and my code in the more detailed page.
[code]
if (isset($HTTP_GET_VARS['pid'])) {  //Display Information

  $query ="SELECT * FROM airticketbooking where empRef='$HTTP_GET_VARS[pid]'";
  $db_query = mysql_query ($query, $db_connection) or die (mysql_error());

echo "Employer RefID: $_POST[empRef]";
}[/code]

when i clicked on the hyperlink in index page, it onli shows "Employer RefID:" but not the $_POST[empRef].
Don't know if i wrote the correct way..please help! Thanks in Advance!
Link to comment
Share on other sites

if you're using a link rather than a form, you want to be using $_GET[variable] not POST.

if you had, [a href=\"http://www.yourdomain.com/details.php?variable=123456\" target=\"_blank\"]http://www.yourdomain.com/details.php?variable=123456[/a]

$_GET[variable] would have a value of 123456.
Link to comment
Share on other sites

I can see you are getting the pid from the querystring, I can follow so far, but then you make a sql query, but you don't do anything with it.

If I assume correctly, the empRef is a field in you database, so you would have to do the following:

[code]
if (isset($HTTP_GET_VARS['pid']))
{  
    $query ="SELECT * FROM airticketbooking where empRef='$HTTP_GET_VARS[pid]'";
    $result = mysql_query ($query) or die (mysql_error());
    $row = mysql_fetch_array($result);
    echo "Employer RefID: " . $row["empRef"];
}
[/code]

or if you just wanted to display the pid that you have in the hyperlink, you could just do:

[code]
if (isset($_GET['pid']))
{  
    echo "Employer RefID: " . $_GET["pid"];
}
[/code]

Koen.
Link to comment
Share on other sites

i tried changing to $_GET[empRef] and i get [a href=\"http://localhost/display.php?pid=09218015\" target=\"_blank\"]http://localhost/display.php?pid=09218015[/a] on the URL adress but on the form, it did not get the information from MySQL and display it out..

Thanks alot Koen Calliauw!! You have solved my problem! Thanks so much!!!
Link to comment
Share on other sites

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.