Jump to content

how do I make a dynamic Link?


Recommended Posts

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

$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">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>


Airfield Name: <? echo $rs["username"]; ?>

<table width="720" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="5">
    <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>
    <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>
    <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>
    <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>
    <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>
    <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>
    <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>
    <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>
    <td colspan="6"><p>Remarks<p><strong><? echo cr($rs["remarks"]); ?></strong></td>
    <td colspan="6"><p>Warnings:</p>
    <p><strong><? echo cr($rs["warnings"]); ?></strong></p>
    <p> </p></td>
    <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>
    <td colspan="6">Google Ifram Image<br /><strong><? echo cr($rs["google_image"]); ?></strong></td>
<p> </p>



Link to comment
Share on other sites

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']; 

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.