Home > Archive > PHP DB > November 2004 > RE: [PHP-DB] Updating count on record results
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [PHP-DB] Updating count on record results
|
|
| Bastien Koert 2004-11-19, 3:56 pm |
| this is how I did it for a client's site
// update the number of times the vehicle has been viewed
mysql_db_query($dbname, "UPDATE vehicle_inventory SET viewed=viewed+1 WHERE
ccode='$ccode'", $link);
bastien
>From: Stuart Felenstein <stuart4m@yahoo.com>
>To: php-db@lists.php.net
>Subject: [PHP-DB] Updating count on record results
>Date: Fri, 19 Nov 2004 04:59:20 -0800 (PST)
>
>I am setting up a table to log a count on individual
>records for every time they are returned in a results
>return.
>
>Just so to illustrate
>
>Record1
>
>First search brings up Record1 (counter is set too 1)
>Second search brings up Record1 (counter is set too 2)
>Third search brings up Record1 (counter is set too 3)
>...etc.
>
>So I have a vauge idea of the sql statement but where
>to place is the question. My thoughts are that it
>should be in the loop that generates the result rows
>return. In other words -
>
>Maybe here :
><?php echo $row_rsVJ['JobTitle']; ?></div></td>
>
>Or maybe here ?:
><?php } while ($row_rsVJ = mysql_fetch_assoc($rsVJ));
>?>
>
>Hope what I'm asking is clear.
>
>Thank you ,
>Stuart
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Stuart Felenstein 2004-11-19, 3:56 pm |
|
--- Bastien Koert <bastien_k@hotmail.com> wrote:
> this is how I did it for a client's site
>
> // update the number of times the vehicle has been
> viewed
> mysql_db_query($dbname, "UPDATE vehicle_inventory
> SET viewed=viewed+1 WHERE
> ccode='$ccode'", $link);
>
Where did this code go though ? Meaning, was it in a
seperate script / page or was it part of a bigger
query that first got the results based on certain
criteria , the did the update?
Stuart
| |
| Bastien Koert 2004-11-19, 3:56 pm |
| its a separate query on the same page, its activated after the data
retreival query runs.
<?
....
// get the information for this vehicle
$result = mysql_db_query($dbname, "SELECT * FROM vehicle_inventory WHERE
ccode='$ccode'", $link);
$data = mysql_fetch_array($result);
$data[comments] = nl2br($data[comments]);
// update the number of times the vehicle has been viewed
mysql_db_query($dbname, "UPDATE vehicle_inventory SET viewed=viewed+1 WHERE
ccode='$ccode'", $link);
....?>
bastien
>From: Stuart Felenstein <stuart4m@yahoo.com>
>To: Bastien Koert <bastien_k@hotmail.com>, php-db@lists.php.net
>Subject: RE: [PHP-DB] Updating count on record results
>Date: Fri, 19 Nov 2004 07:28:48 -0800 (PST)
>
>
>--- Bastien Koert <bastien_k@hotmail.com> wrote:
>
>Where did this code go though ? Meaning, was it in a
>seperate script / page or was it part of a bigger
>query that first got the results based on certain
>criteria , the did the update?
>
>Stuart
|
|
|
|
|