Click to See Complete Forum and Search --> : Setting a link via text gathered from a database


scottyrob
12-26-2005, 05:11 PM
Howdy folks

Below is the code for my page. In the first line it says that Name of the link and the url. then once it is expanded it shows name, url and description. How do i set it so that the url's are links?

Cheers, Fet

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leaders</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="main.css" rel="stylehseet" type="text/css" />

<style type="text/css">
body {
font:14px Arial, Helvetica, sans-serif;
}
.details {
display: none;
font-size:12px;
}
.red_title{
font:20pt Arial;
font-weight:normal;
color:#f00;
}
.button {
background-image: url("admin_area/images/plus.gif");
width: 9px;
height: 9px;
display:block;
float: left;
margin-right: 5px;
margin-top: 2px;
}
</style>

<script type="text/javascript">
function showDetails(memberID,button){
var element = document.getElementById(memberID);
if(element.style.display != 'block'){
element.style.display = 'block';
button.style.backgroundImage = 'url("admin_area/images/minus.gif")';
}else{
element.style.display = 'none';
button.style.backgroundImage = 'url("admin_area/images/plus.gif")';
}
}
</script>
<noscript>
<style type="text/css">
.details {
display: block;
}
</style>
</noscript>
</head>
<body>
<div class="body_bold">
<?php

// Connect to the database server
xxxxxxxxxx


// Select the jokes database
xxxxxxxxxx

?>
<p class="red_title">Links</p>
<blockquote>
<?php

// Request the text of all the jokes
$result = @mysql_query('SELECT * FROM `Links` GROUP BY `ID`'); /* YOU MAY NEED TO EDIT THIS ID SO THAT
IT IS THE SAME AS THE FIELD NAME
IN YOUR DATABASE */
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
$num = mysql_num_rows($result);
echo "<div id=\"alldetails\">";
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
echo "\n<p><input type=\"image\" class=\"button\" id=\"button$i\" value=\" \" onclick=\"showDetails('person$i',this);return true;\"> $row[1] $row[2]</p>\n";
echo "<p id=\"person$i\" class=\"details\">
Title: $row[1]<br>\n
URL: $row[2]<br>\n
Description: $row[3]<br>\n";

}
echo "</div>";
?>
</blockquote>
</div>

</body>
</html>

chazzy
12-26-2005, 05:22 PM
well...

SELECT * FROM `Links` GROUP BY `ID`

i have no idea why you're grouping by id, isn't ID your primary key?

Try this

URL: <a href=$row[2]>$row[2]</a><br>\n