DNA180 Posted July 29, 2013 Share Posted July 29, 2013 Hello guys!!! 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 More sharing options...
birbal Posted July 29, 2013 Share Posted July 29, 2013 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 More sharing options...
Ingolme Posted July 29, 2013 Share Posted July 29, 2013 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 More sharing options...
justsomeguy Posted July 29, 2013 Share Posted July 29, 2013 I think this would work: $count=1; while ($count <= 5){${'photo_'.$count} = $photos_itemrow->{'photo_'.$count};$count++;} 1 Link to comment Share on other sites More sharing options...
DNA180 Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) My friend justsomeguy it is working!!! xDYou are the best!!! :good:Thank you all for your answers!!! Edited July 31, 2013 by DNA180 Link to comment Share on other sites More sharing options...
Don E Posted July 30, 2013 Share Posted July 30, 2013 JSG, Is that jQuery mixed with PHP? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 30, 2013 Share Posted July 30, 2013 No. Javascript does not run inside PHP, you don't mix them. You can use PHP to output Javascript code, but they don't execute at the same time (or on the same computer). http://php.net/manual/en/language.variables.variable.php 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now