update and view news headline
-
I am using this code to view a news headline from mysql table but I want also to add one more thing please... I want to update a field named news_views (int) with +1 everytime someone views this article.. how can I do this please...
<?php
$news_id = $_GET['id'];$conn = mysql_connect('mysql.jassimrahma.com', 'jassimdb', 'xxxxxxx');
$sql = "SELECT * FROM news WHERE news_id = '$news_id'";
mysql_select_db("jassimrahma", $conn) or die(mysql_error());
$result = mysql_query($sql, $conn) or die(mysql_error());
$count = mysql_num_rows($result);if($count == 1)
{
$db_field = mysql_fetch_assoc($result);
$news_url = $db_field['news_url'];
$news_title = $db_field['news_title'];
$news_webpage = file_get_contents($news_url);
// $news_webpage = file_get_contents('http://www.businessweek.com/ap/financialnews/D9RH5MEO0.htm');
echo $news_webpage;
}
else
{
header("location:index.php");
}
?> -
I am using this code to view a news headline from mysql table but I want also to add one more thing please... I want to update a field named news_views (int) with +1 everytime someone views this article.. how can I do this please...
<?php
$news_id = $_GET['id'];$conn = mysql_connect('mysql.jassimrahma.com', 'jassimdb', 'xxxxxxx');
$sql = "SELECT * FROM news WHERE news_id = '$news_id'";
mysql_select_db("jassimrahma", $conn) or die(mysql_error());
$result = mysql_query($sql, $conn) or die(mysql_error());
$count = mysql_num_rows($result);if($count == 1)
{
$db_field = mysql_fetch_assoc($result);
$news_url = $db_field['news_url'];
$news_title = $db_field['news_title'];
$news_webpage = file_get_contents($news_url);
// $news_webpage = file_get_contents('http://www.businessweek.com/ap/financialnews/D9RH5MEO0.htm');
echo $news_webpage;
}
else
{
header("location:index.php");
}
?>I think you will get more response from the PHP forum. :)
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman