User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,967 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,741 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1084 | Replies: 2 | Solved
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

hyperlink in php

  #1  
Nov 26th, 2007
hi
All jobtitle will be displayed in a table with hyperlink.when the jobtitle is clicked.it should fetch description,email etc from the database and display it.
please tell me how to link the pages based on the tobtitle or id....when the hyperlink is clicked it is not displaying the data from the database.

first page.php
echo "<table width='60%' border='1' style='padding-right: 6px'>";
$result=mysql_query("SELECT jobtitle FROM please");
print "<tr><td>jobtitle </td></tr>";
for ($i = 0; $i < mysql_num_rows($result); ++$i)
{

$line = mysql_fetch_row($result);
print "<tr><td><a href='welcome.php'>$line[0]</td></tr>";
}
echo "</table>";


welcome.php
echo "<table width='50%' border='1'>";
$result=mysql_query("SELECT * FROM please where jobtitle='$line'");
for ($i = 0; $i < 1; ++$i)
{
$line = mysql_fetch_row($result);
print "<tr><td>Name</td><td> $line[0]</td></tr>";
print "<tr><td>Company Name</td><td> $line[1]</td></tr>";
print "<TR><td>Company Address </td><td>$line[2]</td></tr>";
print "<tr><td>Email Id </td><td>$line[3]</td></tr>";
print "<tr><td>Job Title</td><td> $line[4]</td></tr>";
}
echo "</table>";
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: hyperlink in php

  #2  
Nov 26th, 2007
you must use the get method or a session to carry your variable to the next page.
this is a sample with the get method:

first page.php
  1. echo "<table width='60%' border='1' style='padding-right: 6px'>";
  2. $result=mysql_query("SELECT jobtitle FROM please");
  3. print "<tr><td>jobtitle </td></tr>";
  4. for ($i = 0; $i < mysql_num_rows($result); ++$i)
  5. {
  6.  
  7. $line = mysql_fetch_row($result);
  8. print "<tr><td><a href='welcome.php?jobtitle=".$line[0]."'>".$line[0]."</td></tr>";
  9. }
  10. echo "</table>";
  11.  

welcome.php

  1. $line=$_GET['jobtitle'];
  2. echo "<table width='50%' border='1'>";
  3. $result=mysql_query("SELECT * FROM please where jobtitle='$line'");
  4. for ($i = 0; $i < 1; ++$i)
  5. {
  6. $line = mysql_fetch_row($result);
  7. print "<tr><td>Name</td><td> $line[0]</td></tr>";
  8. print "<tr><td>Company Name</td><td> $line[1]</td></tr>";
  9. print "<TR><td>Company Address </td><td>$line[2]</td></tr>";
  10. print "<tr><td>Email Id </td><td>$line[3]</td></tr>";
  11. print "<tr><td>Job Title</td><td> $line[4]</td></tr>";
  12. }
  13. echo "</table>";
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: hyperlink in php

  #3  
Nov 26th, 2007
thanks it is working
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC