LivingReceiver Posted January 5, 2014 Share Posted January 5, 2014 Hi there! I am trying to get a list of images in line with each other-- the only thing giving me trouble is the fact that I want the last picture to be randomly chosen from an array of images. Everything seems to work just fine except for the fact that the randomized image and the other images won't stay on the same line. In other words, I want the images to show up like this: xxxxxxrandom ..but it keeps showing up like this: xxxxxx random <html> <text><red><large><i>Processing may take up to five seconds. You will be redirected shortly.</i></large></red></text><p> <meta http-equiv="refresh" content="5;url=entries.php"> <img src="base.gif" width="10" height="36"/> <img src="base2.gif" width="10" height="36"/> <img src="base3.gif" width="10" height="36"/> <img src="base4.gif" width="10" height="36"/> <img src="base5.gif" width="10" height="36"/> <img src="base6.gif" width="10" height="36"/> <?php $pic = array('50.gif','100.gif','200.gif','250.gif','150.gif','300.gif'); shuffle($pic); ?> <?php for( $i = 0; $i < 1; $i++) echo "<li style=\"display: inline;\"> <img src=\"$pic[$i]\" width=\"27\" height=\"36\"> </li>"; ?> </html> Would anyone be able to tell me what I may be doing wrong? Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/285121-html-and-php-wont-fit-on-same-line-in-output/ Share on other sites More sharing options...
ginerjm Posted January 6, 2014 Share Posted January 6, 2014 I'd start by writing better html. Have no idea what your first few lines are doing. As for keeping things on a line.it all depends on the width of your available screen space. Are you controlling that somewhere? (Tip: try using single quotes in place of your slash-double quotes. It's not only easier to write but much easier to read.) Quote Link to comment https://forums.phpfreaks.com/topic/285121-html-and-php-wont-fit-on-same-line-in-output/#findComment-1463991 Share on other sites More sharing options...
Solution hansford Posted January 6, 2014 Solution Share Posted January 6, 2014 Added some additions. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="refresh" content="5;url=entries.php"> </head> <body> <text><red><large><i>Processing may take up to five seconds. You will be redirected shortly.</i></large></red></text><p> <div style="display:block;"> <img src="base.gif" width="10" height="36"/> <img src="base2.gif" width="10" height="36"/> <img src="base3.gif" width="10" height="36"/> <img src="base4.gif" width="10" height="36"/> <img src="base5.gif" width="10" height="36"/> <img src="base6.gif" width="10" height="36"/> <?php $pic = array('50.gif','100.gif','200.gif','250.gif','150.gif','300.gif'); shuffle($pic); ?> <?php for( $i = 0; $i < 1; $i++) echo "<li style=\"display: inline;\"> <img src=\"$pic[$i]\" width=\"27\" height=\"36\"> </li>"; ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/285121-html-and-php-wont-fit-on-same-line-in-output/#findComment-1463992 Share on other sites More sharing options...
ginerjm Posted January 6, 2014 Share Posted January 6, 2014 What does this do for you? for ($I=0; $I<1; $I++) Why not just echo $pic[0] ? So anyway - you have a div that is of unknown width; perhaps that is the problem. Also - I am unaware of any <large> or <red> or <text> html tags. Are these something new? Quote Link to comment https://forums.phpfreaks.com/topic/285121-html-and-php-wont-fit-on-same-line-in-output/#findComment-1463995 Share on other sites More sharing options...
LivingReceiver Posted January 6, 2014 Author Share Posted January 6, 2014 (edited) What does this do for you? for ($I=0; $I<1; $I++) Why not just echo $pic[0] ? So anyway - you have a div that is of unknown width; perhaps that is the problem. Also - I am unaware of any <large> or <red> or <text> html tags. Are these something new? I was receiving help on my array and I was told to add that... (I realize my coding is very sloppy-- I haven't worked on coding for about five years.) No, those aren't new-- those were supposed to be deleted, but I suppose I forgot. I was messing around with some HTML.. I vaguely remembered those tags working, but my memory of this is pretty much shot. Thank you for you suggestion! I'll let you know how it goes. Added some additions. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="refresh" content="5;url=entries.php"> </head> <body> <text><red><large><i>Processing may take up to five seconds. You will be redirected shortly.</i></large></red></text><p> <div style="display:block;"> <img src="base.gif" width="10" height="36"/> <img src="base2.gif" width="10" height="36"/> <img src="base3.gif" width="10" height="36"/> <img src="base4.gif" width="10" height="36"/> <img src="base5.gif" width="10" height="36"/> <img src="base6.gif" width="10" height="36"/> <?php $pic = array('50.gif','100.gif','200.gif','250.gif','150.gif','300.gif'); shuffle($pic); ?> <?php for( $i = 0; $i < 1; $i++) echo "<li style=\"display: inline;\"> <img src=\"$pic[$i]\" width=\"27\" height=\"36\"> </li>"; ?> </div> </body> </html> Thank you so much! Edit: Tried the code hansford fixed, and the problem was solved. Ginerjim, you were completely right about the solution. Thank you so much! Edited January 6, 2014 by LivingReceiver Quote Link to comment https://forums.phpfreaks.com/topic/285121-html-and-php-wont-fit-on-same-line-in-output/#findComment-1464001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.