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
https://forums.phpfreaks.com/topic/116420-solved-make-a-link/
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
https://forums.phpfreaks.com/topic/116420-solved-make-a-link/#findComment-598672
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
https://forums.phpfreaks.com/topic/116420-solved-make-a-link/#findComment-598688
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.