Jump to content

HTML and PHP won't fit on same line in output


LivingReceiver
Go to solution Solved by hansford,

Recommended Posts

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!

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

  • Solution

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>
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by LivingReceiver
Link to comment
Share on other sites

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.