VinceGledhill Posted August 30, 2011 Share Posted August 30, 2011 Hi people. I am trying to make a dynamic link in my output form. The link goes something like this - <a href="http://microlight.co/vince_php/printcard.php?id=96">Printable Card</a> However, I would like the $id of the record from the actual page that I am loading. In other words, I would like the Printable Card to be the same "$id" as the card that it is linked from. Please can someone tell me how to code the above line? I've tried it like this and many other combinations thereof but can't seem to crack it. - <a href="http://microlight.co/vince_php/printcard.php?id=<?"$id"?>">Printable Card</a> Here is my whole output card <?php $host = 'localhost'; $usr = "username"; $password = 'thepassword'; $db_name = 'sitename'; function cr($string){ $clean_string = str_replace("\r\n","<BR>",$string); return $clean_string; } if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from users where user_id = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> Airfield Name: <? echo $rs["username"]; ?> <table width="720" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="5"> <tr> <td width="120" bgcolor = #E6F8EB>Height Above MSL</td> <td width="120" bgcolor = #E6F8EB>Mb Difference</td> <td width="120" bgcolor = #E6F8EB>Alternative</td> <td width="120" bgcolor = #E6F8EB>PPR?</td> <td width="120" bgcolor = #E6F8EB>Location General</td> <td width="120" bgcolor = #E6F8EB>Location Grid Ref:</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo cr($rs["height_above"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["mb_diff"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["alternative"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["ppr"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["general_location"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["location_grid"]); ?></strong></td> </tr> <tr> <td bgcolor = #f7e5c6>Runway Numbers</td> <td bgcolor = #f7e5c6>Circuit Direction</td> <td bgcolor = #f7e5c6>Circuit Height</td> <td bgcolor = #f7e5c6>Runway Length</td> <td bgcolor = #f7e5c6>Runway Surface</td> <td bgcolor = #f7e5c6>Food? </td> </tr> <tr> <td bgcolor = #f7e5c6><strong><? echo cr($rs["runway_numbers"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["circuit_direction"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["circuit_height"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["runway_length"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["surface"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["food"]); ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Radio Frequency</td> <td bgcolor = #E6F8EB>Radio Callsign</td> <td bgcolor = #E6F8EB>Radio Type</td> <td bgcolor = #E6F8EB>Other Radio</td> <td bgcolor = #E6F8EB>Fuel?</td> <td bgcolor = #E6F8EB>Landing Fee £</td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo cr($rs["radio_frequency"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["radio_callsign"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["radio_type"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["other_radio"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["fuel"]); ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo cr($rs["landing_fee"]); ?></strong></td> </tr> <tr> <td bgcolor = #f7e5c6>Opperating Hrs</td> <td bgcolor = #f7e5c6>Maintenance</td> <td bgcolor = #f7e5c6>Hangarage</td> <td bgcolor = #f7e5c6>Parking</td> <td bgcolor = #f7e5c6>Accommodation</td> <td bgcolor = #f7e5c6>School ?</td> </tr> <tr> <td bgcolor = #f7e5c6><strong><? echo cr($rs["operating_hours"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["maintenance"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["hangarage"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["parking"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["accommodation"]); ?></strong></td> <td bgcolor = #f7e5c6><strong><? echo cr($rs["school"]); ?></strong></td> </tr> <tr> <td colspan="6"><p>Remarks<p><strong><? echo cr($rs["remarks"]); ?></strong></td> </tr> <tr> <td colspan="6"><p>Warnings:</p> <p><strong><? echo cr($rs["warnings"]); ?></strong></p> <p> </p></td> </tr> <tr> <td colspan="3"><p>Website: </p> <p><strong><? echo cr($rs["weblinks"]); ?></strong></p></td> <td colspan="3"><p>Operator:</p> <p><strong><? echo cr($rs["operator"]); ?></strong></p></td> </tr> <tr> <td colspan="6">Google Ifram Image<br /><strong><? echo cr($rs["google_image"]); ?></strong></td> </tr> </table> <p> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/246072-how-do-i-make-a-dynamic-link/ Share on other sites More sharing options...
SnapGravy Posted August 31, 2011 Share Posted August 31, 2011 You need to echo the ID to get it to show in the address bar. Any code you want to output from PHP needs a command to print it out. (As far as I know) Also forgot some curlies in there (I believe). <a href="http://microlight.co/vince_php/printcard.php?id=<?php echo $id ?>">Printable Card</a> if (!isset($id)) { $id = $_GET['id']; } Quote Link to comment https://forums.phpfreaks.com/topic/246072-how-do-i-make-a-dynamic-link/#findComment-1263741 Share on other sites More sharing options...
VinceGledhill Posted August 31, 2011 Author Share Posted August 31, 2011 Brilliant mate thanks. Quote Link to comment https://forums.phpfreaks.com/topic/246072-how-do-i-make-a-dynamic-link/#findComment-1263822 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.