Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print an article to screen

Status
Not open for further replies.

dagger2002

Programmer
Nov 23, 2004
172
US
I have my database and it connects to my site.
I was wondering how to print the information on a specific article when i give it the id.

heres the connection string
Code:
<?
	$ntouquery = "SELECT id, title, text, date FROM stories WHERE include = 1 AND supe = 0 ORDER BY date DESC";
	$ntouresult = mysql_query($ntouquery) or die("Error with the query.");
	$num_ntou_rows = mysql_num_rows($ntouresult);
	while ($row = mysql_fetch_array($ntouresult)) {
		echo "<li><a href=\"$thisURL/comm_newsPR.php?id=$row[0]\"> $row[1]</a></li>";
//		<a href=\"$thisURL/comm_newsPR.php?id=$ntourows[0]\">$ntourows[1]</a>
	}
?>

thanks
David
 
what do you mean by print

- print to screen
- or print to printer
 
What seems to be the problem? In comm_newsPR.php you should open a query that reads the information from the database that contains the message of the article. Something in the likes of
Code:
$query = "SELECT id, title, text, date FROM stories WHERE id = " . $_GET['id'];
From there on it is just outputting the result (same as the aforementioned page) and styling the information. If you have specific question about any of those, let us know.
 
Code:
print $row['text'];
# or
echo $row['text'];
 
I'm sorry, but there must be some part of the communication getting lost or there must be some misunderstanding.
Here are the steps:
1. Page is built the first time, list of anchors is produced.
2. The anchor leads to the script itself now with a GET parameter appended that indicates the link clicked on.
3. Script looks if there is a value in the GET param and uses Vragabnod's SQL to retrieve the row.
4. The text is printed using echo or print.

These are the steps; skeleton code:
Code:
if (isset($_GET['id'])){
   $ SQL =  "SELECT id, title, text, date FROM stories WHERE id = " . $_GET['id'];
    $result = mysql_query($SQL) or die("Error with the query.");
    $row = mysql_fetch_array($result));
   print $text;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top