Jump to content

PHP variables using while statement!


DNA180

Recommended Posts

Hello guys!!! :good:

 

I think I need some help here... I have make a database query and some variables that take values from this query. Variables look like this...

$photo_1  = $photos_itemrow->photo_1;$photo_2  = $photos_itemrow->photo_2;$photo_3  = $photos_itemrow->photo_3;$photo_4  = $photos_itemrow->photo_4;$photo_5  = $photos_itemrow->photo_5;

What I want to do is to make this variables using WHILE for example. Something like this...

$count=1; while ($count <= 5){${'photo_'.$count} = ${'photos_itemrow->photo_'.$count};$count++;}

Or like this...

$count=1; while ($count <= 5){${'photos_itemrow->photo_'.$count};$count++;}

But none of those two way is working!!! Does anybody have any idea how to do this???Thank you in advance!!!

Link to comment
Share on other sites

JQuery is like JS, works on clientside. mixing with php wont work. can you tell what are you trying to accomplish actually?

Link to comment
Share on other sites

This is what arrays are for.

 

$photos[$count]

 

You should try to get $photos_itemrow->photo to be an array, wherever you created it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...