Jump to content

couting help


tyfobpo

Recommended Posts

hello, i am still pretty new to php/mysql. currently, on my ste i have conversations which i post on the site. i made it so that theres an admin area, i post the convo and it adds it to the database, then use a page to view the conversation when its link is clicked./ well i added a new field to my table called count, with the goal of making it so everytime a link is clicked, it adds 1 to the count field for that row. but its not working, the count field have stayed at zero. here is my code.

 

// Make a mysql Connection
mysql_connect(localhost,$user,$pass);
@mysql_select_db($db) or die( "Unable to select database");


if($_GET['id'])
{
$theid=$_GET['id'];
$query = 'select * from convo where id='.$_GET['id'];
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
//display page
echo $row['info'];
//count page
$counter=$row['count'];
$newcount=$counter+1;
mysql_db_query($db, "update convo set id='',who='',date='',time='',name='',info='' count='$newcount' where id='$theid'") or die(mysql_error());
}
?>

Link to comment
https://forums.phpfreaks.com/topic/80842-couting-help/
Share on other sites

mysql_connect(localhost,$user,$pass);
@mysql_select_db($db) or die( "Unable to select database");


if(isset($_GET['id']))
{
$theid=$_GET['id'];
$query = "SELECT * FROM convo WHERE id=$theid";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);
//display page
echo $row['info'];
//count page
$newcount=$row['count']++;
mysql_query("UPDATE convo SET count=$newcount WHERE id=$theid") or die(mysql_error());
}
?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/80842-couting-help/#findComment-410233
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.