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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.