Jump to content

Recommended Posts

Hi everyone,

 

Im about to build an update record but im unsure how it will work and how I code it  :-\.

I have a page of photographs. users can select multiple photos which are then stored in a db with his session id.

The session id is then passed to paypayl with the price where the user pays and is redirected back to my site. When redirected back to my site, the session id is posted back and so all the photographs are listed ready for download.

 

I need to implement an update "photo downloads" column +1 everytime its downloaded, does this make sense? Id greatly appreciate ANY help!, thanks

Link to comment
https://forums.phpfreaks.com/topic/202685-update-record-problem/
Share on other sites

Thanks Karl, My only concern is the data is coming in from just 1 variable? So would I have to query the db to say, Get all "picids" from the database where session name = $sessionvariable, then +1 and insert? if that makes sense?

Just realised it cant work! I have 2 tables, 1 with al lthe photo details etc incl. download counter. and then the 1 which holds the pic id and session id. So it would need to take the pic id from the session table and find the pic id in the photos table and then update, does this make sense?

Here's some information that could help.

http://dev.mysql.com/doc/refman/5.1/en/join.html

 

In your instance, you have a common field, pic id. So that would just be a easy join.

 

SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;

 

Possibly. Idk, I'm clueless, I should really read up on them. I've just never had a reason to.

So it would need to take the pic id from the session table and find the pic id in the photos table and then update, does this make sense?

$query = mysql_query("SELECT s.id, p.* FROM `session_table` as s, `photos_table` as p WHERE p.id = s.id");

You might need the change s.id to the pic id, so it would get the pic id. The 's.' has to stay there, so change id. If you have a image id session or whatever, add in another where before p.id = s.id. If you get me, you'll need to provide more information, and possibly some code.

 

To update.. depending on what you are trying to do...

$query = mysql_query("UPDATE 'photos' WHERE ... ..");

 

Hope this makes more sense, although you'd need to post code to be able to get better help.

Thanks teddy Killer, I dont quite understand how it works but ill try my best! my current code to selecte all the picture names from the db is

mysql_select_db($database_saucy_connection, $saucy_connection);
$query_getses = sprintf("SELECT photo_downloads.id, photo_downloads.photo_id, photo_downloads.sess_id, photo_downloads.photo_name, photo_downloads.photo_price, model_pictures.id, model_pictures.user_picture, model_pictures.picture_downloads FROM photo_downloads, model_pictures WHERE model_pictures.id=photo_downloads.photo_id AND sess_id = %s ", GetSQLValueString($colname_getses, "text"));
$query_limit_getses = sprintf("%s LIMIT %d, %d", $query_getses, $startRow_getses, $maxRows_getses);
$getses = mysql_query($query_limit_getses, $saucy_connection) or die(mysql_error());
$row_getses = mysql_fetch_assoc($getses);

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.