Jump to content

[SOLVED] make a link


cleary1981

Recommended Posts

Hi I have the following code that displays the name and descriptions for each record in my table. The trouble is i want the name to be a clickable link. Can this be done?

 

heres my code

<?php
if ($_COOKIE["cost"] == "1") {

} else {
//redirect back to login form if not authorised
header ("Location: loginform.html");
exit;
}

require "config.php";
$sql="select module_name, mod_desc from module where confirmed=0";
$result = mysql_query($sql) or trigger_error(mysql_error());
?>
<table border="6" cellspacing="2" cellpadding="2">
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<?php
while($nt=mysql_fetch_array($result)){
echo "<tr><td>$nt[module_name]</td><td> $nt[mod_desc]</td></tr>";     // name class and mark will be printed with one line break at the end
}
?>

Link to comment
Share on other sites

<?php
if ($_COOKIE["cost"] == "1") {

} else {
//redirect back to login form if not authorised
header ("Location: loginform.html");
exit;
}

require "config.php";
$sql="select module_name, mod_desc from module where confirmed=0";
$result = mysql_query($sql) or trigger_error(mysql_error());
?>
<table border="6" cellspacing="2" cellpadding="2">
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<?php
while($nt=mysql_fetch_array($result)){
print "<tr><td><a href=\"mypagehere.php\">{$nt['module_name']}</a></td><td> $nt[mod_desc]</td></tr>";     // name class and mark will be printed with one line break at the end
}
?>

Link to comment
Share on other sites

Well, you need to start by having a unique field in your DB table.  Maybe an autoincrementing integer.

 

Then, assuming you have that... you could use this....

 

<?php
if ($_COOKIE["cost"] == "1") {

} else {
//redirect back to login form if not authorised
header ("Location: loginform.html");
exit;
}

require "config.php";
$sql="select module_name, mod_desc from module where confirmed=0";
$result = mysql_query($sql) or trigger_error(mysql_error());
?>
<table border="6" cellspacing="2" cellpadding="2">
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<?php
while($nt=mysql_fetch_array($result)){
print "<tr><td><a href=\"" . $_SERVER['PHP_SELF'] . "?id={$nt['my_id_field']}\">{$nt['module_name']}</a></td><td> $nt[mod_desc]</td></tr>";     // name class and mark will be printed with one line break at the end
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.