Jump to content


Photo

Problem with Hyperlink


  • Please log in to reply
3 replies to this topic

#1 takeiteasy

takeiteasy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 28 April 2006 - 09:18 AM

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

and my code in the more detailed page.
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]"; 
}

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!

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 28 April 2006 - 09:24 AM

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.
wisewood: proven fact, I am both wise, and wooden.

#3 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 28 April 2006 - 09:30 AM

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:

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"];
}

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

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

Koen.

#4 takeiteasy

takeiteasy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 28 April 2006 - 09:36 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users