Php-Mysql, select and update trouble
| From: | Alessandro Folghera | Date: | Sun, 27 Jun 2004 08:01:57 +0000 |
| Subject: | Php-Mysql, select and update trouble | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35000@lists.php.net to get a copy of this message | ||
Dear Phpers,
I have the following part of a script that retrieve an URL site. I'd like
to count the clicks for every URL. I have added to mysql table a column
"hit". May anybody tell me how to insert into an sql selection also an
update, referring to the HIT variable (i.e. to realize a select and update
together) ?
This is the select I'm using:
<?
require("../connection.php");
$link = mysql_connect($host,$user,$password);
$result=mysql_db_query($base,"select url from ".$baseofsites." where
id=".$s." ",$link);
$url = mysql_result($result,0,"url");
header("Location: ".$url."");
exit();
?>
This should be (I suppose) the sql update I must include ... UPDATE
table.sites SET hit = hit + 1 WHERE id=$s
Thanks for all, Alessandro