[SOLVED] detail record from URL
Posted: Thu Dec 04, 2003 12:05 pm
HI,
Sorry Im new to this and I have a very basic question (No doubt!)
I have created a news database which holds news articles, I have created a script which returns a list of all articles and turns the title into a URL click through to read more.
So the URL looks similar to /news_detail.php?id=96
I want to then query the same database to bring back this record with that id number. All I get is a blank page though, what am I doing wrong?
I have the following code on the recipient page:
Sorry Im new to this and I have a very basic question (No doubt!)
I have created a news database which holds news articles, I have created a script which returns a list of all articles and turns the title into a URL click through to read more.
Code: Select all
<a href="news_detail.php?id=".$dataї'sid']."">".$dataї'title']."</a>I want to then query the same database to bring back this record with that id number. All I get is a blank page though, what am I doing wrong?
I have the following code on the recipient page:
Code: Select all
<?php
$id = $_postї'id'];
$dbconn = mysql_connect("localhost", "username", "password");
$result = mysql_select_db("database", $dbconn);
if ( $result == false)
{
echo mysql_error();
} else {
$sql = "SELECT title, maintext, cdate FROM impro_news WHERE sid = '$id'";
$result = mysql_query( $sql );
if ( $result != false )
{
$data = mysql_fetch_assoc( $result );
echo "<table width="50%" border="0" cellspacing="0" cellpadding="0">";
echo "<tr>" ;
echo "<td width="75%">$dataїtitle]</td>";
echo "<td width="25%">$dataїcdate]</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan="2">$dataїmaintext]</td>";
echo "</tr>";
echo "</table>";
} else {
echo mysql_error();
}
}
?>