takeiteasy Posted April 28, 2006 Share Posted April 28, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/8615-problem-with-hyperlink/ Share on other sites More sharing options...
wisewood Posted April 28, 2006 Share Posted April 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/8615-problem-with-hyperlink/#findComment-31593 Share on other sites More sharing options...
koencalliauw Posted April 28, 2006 Share Posted April 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/8615-problem-with-hyperlink/#findComment-31595 Share on other sites More sharing options...
takeiteasy Posted April 28, 2006 Author Share Posted April 28, 2006 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/8615-problem-with-hyperlink/#findComment-31596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.