You are here: Updating MySQL tables with user-variable incrementing and resetting. « PHP SQL « IT news, forums, messages
Updating MySQL tables with user-variable incrementing and resetting.

Posted by Rik on 05/30/06 12:12

Lets say I have:
table 'tbl_houses':
- id
- adress
- etc....

and:
table 'tbl_house_photos'
- id
- filename
- house_id
- default (tinyint(1))

It used to be that only one of the photos was 'default' (i.e. '1'), the rest
of the photos was '0'. Now we want to change this to an order, default image
as the first, the rest in order of the filename for starters, afterwards the
order can be changed.

I can simply change the 'default' to tinyint(2) (there will never be more
then 99 photos, a lot less actually), and loop in PHP on every known house,
and update the value accordingly.

I was actually wondering wether I could to this in a direct query, like:
UPDATE tbl_images SET 'order' = (IF(`house_id`=@hd,@count+1,'1'), ORDER BY
`house_id`, `default`, `filename`

and then somehow some code to set @hd & @count....

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация