Jump to content

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??

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.