<?php
include 'config.php';
include 'opendb.php';

$result = mysql_query("SELECT * FROM 888db ORDER BY id") 
or die(mysql_error());  
 

echo "<table border='0'>";
echo "<div id='bodyframe'>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
	// Print out the contents of each row into a table
	echo "<tr><td>"; 
	echo $row['topic'];
	echo "</td></tr>"; 
	
} 
echo "</div>";
echo "</table>";
include 'closedb.php';
?>

I want to 'topic' to be clickable to access rest of the article.

Recommended Answers

All 7 Replies

You want the rest of the article to come up in a new page or somewhere on the same page?

Yh thanks. different page please. I manage to put url in it but cannot seem to get it to work

<a href=\"detail.php?topic=$row[0]\">$row[0]</a>

the site is at sharewink.com

Try this...

echo "<a href=\"detail.php?topic=" . $row['topic'] . "\">" . $row['topic'] . "</a>";

Btw the code tags on this forum are in [] brackets, not <>.

Yh i have done that but keep getting page not found 404 error. I want it to have it's own page that when i click the hyperlink, takes me on to that page of that topic. How do i go about it? Hope u understand what i mean. Thank you in advance.
If it helps the website is at http://www.sharewink.com. When you click on those links it shows the topic in the browser but fails to have a page. Although i have designed a page called detail.php but how will i do it so that, it knows which row of an article to show

I looked at your page and I'm not getting a 404 error, just no data. Anyway as far as setting it all up right, my advice would first be to send the id instead of topic...

echo "<a href=\"detail.php?topicid=" . $row['id'] . "\">" . $row['topic'] . "</a>";

Then in your details.php you can access that with $_GET...so you could do something like

$result = mysql_query("SELECT * FROM 888db where id=" . $_GET['topicid'])

Thank you but how i do print it? use echo? if you don't mind can u please tell me how. I have done the query but how do i get it to show on detail.php? Thank you i know i seem like a nob .

Yes echo is what you want to use.
1: You get the results from the database.
2: Fetch the first row of results into an associative array.
3: Print the desired field from the array.

$result = mysql_query("SELECT * FROM 888db where id=" . $_GET['topicid'])
if($row = mysql_fetch_array($result, MYSQL_ASSOC)){
	echo $row['details'];
}

Where 'details' in $row is replaced by whatever the field name is in your database table that contains the text you want to show.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.