<?php
if (some coding here)
{
die("Article not found!");
}
else
{
//some coding here
}
?>
<?php
$id = $_POST['id']; // or $_GET['id']
$sql = mysql_query("SELECT * FROM news WHERE id = $id");
require('./config.php');
if($sql) {
if($row = mysql_fetch_array($sql)) {
echo " " . $row['title'] . "<br><br>";
echo " " . $row['story'] . "<br><br>";
echo " " . $row['author'] . "<br><br><br>";
}
else {
?>
<font color="red"><b>Article not found</b></font>
<?php } } ?>
<?php
$news_id = mysql_real_escape(strip_tags( $_GET['id'] ) );
if( !$news_id )
{
echo 'No News article selected!';
}
else
{
$check = mysql_query( "SELECT * FROM news_articles WHERE `id` = '$news_id'" );
if( mysql_num_rows( $check ) == 0 ) //article not found/doesn't exist
{
echo 'This news article does not exist!';
}
else
{
$n = mysql_fetch_array( $check ); //get all rows from the news article
echo '<h1>' . $n["title"] . '</h1><p>' . $n["content"] . '</p>';
}
}
?>
This should work:
PHP:<?php $news_id = mysql_real_escape(strip_tags( $_GET['id'] ) ); if( !$news_id ) { echo 'No News article selected!'; } else { $check = mysql_query( "SELECT * FROM news_articles WHERE `id` = '$news_id'" ); if( mysql_num_rows( $check ) == 0 ) //article not found/doesn't exist echo 'This news article does not exist!'; } else { $n = mysql_fetch_array( $check ); //get all rows from the news article echo '<h1>' . $n["title"] . '</h1><p>' . $n["content"] . '</p>'; } } ?>
<?php
$news_id = mysql_real_escape(strip_tags( $_GET['id'] ) );
if( !$news_id )
{ //starts
echo 'No News article selected!';
} //ends
else
{ // starts
$check = mysql_query( "SELECT * FROM news_articles WHERE `id` = '$news_id'" );
if( mysql_num_rows( $check ) == 0 ) //article not found/doesn't exist
echo 'This news article does not exist!';
} // ends
else
{ //start
$n = mysql_fetch_array( $check ); //get all rows from the news article
echo '<h1>' . $n["title"] . '</h1><p>' . $n["content"] . '</p>';
} //ends
} // nothing ?!
?>
}
else
{
}else{
Just to clear things out, that is wrong.No ?
PHP:<?php $news_id = mysql_real_escape(strip_tags( $_GET['id'] ) ); if( !$news_id ) { //starts echo 'No News article selected!'; } //ends else { // starts $check = mysql_query( "SELECT * FROM news_articles WHERE `id` = '$news_id'" ); if( mysql_num_rows( $check ) == 0 ) //article not found/doesn't exist echo 'This news article does not exist!'; } // ends else { //start $n = mysql_fetch_array( $check ); //get all rows from the news article echo '<h1>' . $n["title"] . '</h1><p>' . $n["content"] . '</p>'; } //ends } // nothing ?! ?>
<?php
$news_id = mysql_real_escape(strip_tags( $_GET['id'] ) );
if( !$news_id )
{ //starts
echo 'No News article selected!';
} //ends
else
{ // starts
$check = mysql_query( "SELECT * FROM news_articles WHERE `id` = '$news_id'" );
if( mysql_num_rows( $check ) == 0 ) //article not found/doesn't exist
[B] { [/B] //start
echo 'This news article does not exist!';
} // ends
else
{ //start
$n = mysql_fetch_array( $check ); //get all rows from the news article
echo '<h1>' . $n["title"] . '</h1><p>' . $n["content"] . '</p>';
} //ends
} [B] /*end*/ [/B]
?>