Jump to content

insert and update at same time and add ++


Lisa23

Recommended Posts

Hi i need to count the number items in an album now on the album i have create a field called count which counts the number items in that album

 

but now i dnt knw how to update those as soon insert a item in the table item

 

so i thought woul be possible to create a script that when insert data into item tables also update album table row count by adding one like update count with A now A equal row count ++1  any help on start of it if possible???/

Link to comment
https://forums.phpfreaks.com/topic/213525-insert-and-update-at-same-time-and-add/
Share on other sites

i tried like this but did not work any help please

 

	$sql = "INSERT INTO " .PHOTOS_TABLE. "
	(
		photo_name,
		photo_date,
		photo_proper,
		photo_size,
		album_id
	)
	VALUES
	(
		'" .addslashes($photo_name). "',
		" .time(). ",
		'" .addslashes($key_name). "',
		" .intval($size). ",
		" .$album. "
	)";


$update_query="UPDATE albums set $count=count+'1' WHERE $count=count"; // total will be updated to total+number of new puppies added.

mysql_query($update_query);

Hi i need to count the number items in an album now on the album i have create a field called count which counts the number items in that album

 

And why you want to do that?.... when a simple query counting the records in your photo_table while you are displaying the records from your album should do the job?

well each photos has an album id now if i count number photos in photos table how can i define count number of photo with id 1 and id 2 and id 3 then each one display on specific album like album digital number items 5 album media number item 7 how can i do that i know to caount all the items in the photo table bt how is gona diferentiate by the id number??

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.