Hi,
I am trying to write a links page that as has follows.
- Image + URL (an image with a URL to click and redirect to the relevent link).
- Date added.
- Hits (a count of how many times the above image + URL was clicked).
- Description (a brief description of the link).
Here is the script I am using but it wont work could someone modify it so it works.
MySQL
CREATE TABLE `portal_links` (
`link_id` mediumint(8) NOT NULL auto_increment,
`link_image` varchar(255) NOT NULL default '0',
`link_url` varchar(255) NOT NULL default '0',
`link_date` varchar(255) NOT NULL default '01/01/2005',
`link_hits` int(11) NOT NULL default '0',
`link_description` text,
PRIMARY KEY (`link_id`)
) TYPE=MyISAM;
INSERT INTO `portal_links` VALUES (1, 'images/banners/codezwiz88x31.gif', 'codezwiz.com', '22/05/2005', 0, 'A site that specialise in PHP-Nuke services.');
INSERT INTO `portal_links` VALUES (2, 'images/banners/huricane88x31.gif', 'huricaneinc.com', '22/05/2005', 0, 'A very good gaming / graphics discussions forum.');
PHP
<?php
$conn = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("davidtomneyuk, $conn) or die(mysql_error());
$get = "SELECT link_id, link_image, link_url, link_date, link_hits, link_description FROM portal_links ORDER BY link_id";
$getall = mysql_query($getall, $conn) or die(mysql_error());
if (mysql_num_rows($getall) < 1) {
$display_block = "<p><em>No links exist.</em></p>";
} else {
$display_block = "<table cellpadding=3 cellspacing=1 border=1><tr><th>LINK</th><th>INFO</th></tr>";
while ($info = mysql_fetch_array($getall)) {
$link_id = $info['link_id'];
$link_image = $info['link_image'];
$link_url = $info['link_url'];
$link_date = $info['link_date'];
$link_hits = $info['link_hits'];
$link_description = $info['link_description'];
$display_block .= "<td align=center width=40% height=40 class=row3 valign=center><a href=links.php?link_id=$link_id target=blank><img src=$link_image width=88 height=31 border=0></a></td>";
}
$display_block .= "</table>";
}
?>
<html>
<head>
<title>Links</title>
</head>
<body>
<h1>LINKS</h1>
<?php print $display_block; ?>
</body>
</html>
Thankyou