Hi All,
I was wondering if anyone could help me out with this.
I have a MYSQL db with 3 tables:
item
type
site
in the type table i have stored the URL of the page e.g. http://www.yourdomain.com/page.php
my PHP code is as below:
<?php
// Connect to the database server
$dbcnx = @mysql_connect('Address', 'Username', 'Password');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the jokes database
if (!@mysql_select_db('joke')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
$result = @mysql_query('SELECT type_name, type_url, count(*) as count
FROM item, type
WHERE type.type_id = item.type_id
GROUP BY type_name');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)){
echo $row['type_name'], ' ', '(', $row['count'], ')'. '<br>';
}
?>
The page can be found at http://www.personally-yours.co.uk/development/tester.php
what I'm trying to do is to display the hyperlink for each row in the type table e.g
Certificate - http://www.yourdomain.com/page.php
so the result would be a hyperlink on certificate to the proper page.
Can this be done by encasing the
while ($row = mysql_fetch_array($result)){
echo $row['type_name'], ' ', '(', $row['count'], ')'. '<br>';
}
in a <a href> I've tried every way so far and I have select the type_url within my query so that it is selected.
Can this be done with a <a href>???? so that the result is the list of types along with a count with each one that has a hyperlink to the page.
any help would be appreciated.
Many Thanks