Jump to content

WHILE LOOP PIC AND NAME


Techmate

Recommended Posts

I am have an issue looping a picture with the name of the a person under it. My loop comes out with the name and picture next to each other. I need it to look like this.

 

pic                pic                pic            pic

name          name          name        name

 

while ($list = mysql_fetch_assoc($sql)) {

$name=$list['image'];
$name=$list['name'];


echo "<h1>" . $name . "</h1>" . "<img src=get.php?id=$listidagain&dbchange=$dbc width=40% border=0></a>";

} 

Link to comment
Share on other sites

Hi techmate,

 

what i would do is wrap it up in a div and float that one. Also instead of using a h1 element i rather use a h3 element but that is up to you.

here is what i would do. Also I see you have a anchor closing tag but not a beginning one so i removed that for now. I also added an alt tag for the image always wise to include that for seo purposes if used correctly.

 

while ($list = mysql_fetch_assoc($sql)) {

$name=$list['image'];
$name=$list['name'];


echo '<div class="person"><h3>' . $name . "</h3>" . '<img src="get.php?id=$listidagain&dbchange=$dbc" width="40%" border="0" alt=""></div>';

} 

than in css you just do

div.person{float:left;margin:10px;}

Link to comment
Share on other sites

I tried it and it works with text but not images? Do you have another way?

This should work just fine with images(if the dimensions are correct). If you have an online example of what you say is not working I am happy to have a look at it.

 

Link to comment
Share on other sites

Look at your source:

 

<div class="person">
  <h3>
    <img width="40%" border="0</h3" src="get.php?id=23&dbchange=Test">Test<br>
  </h3>
</div>

don't place the image inside the <h3> element. Do as this

<div class="person">
  <img width="40%" border="0</h3" src="get.php?id=23&dbchange=Test">
  <h3>
    Test
  </h3>
</div>

Also it would be smart to give Div with class person some fixed dimensions so it looks the same for each item

just add the dimension to the class. for instance:

div.person {
    background: none repeat scroll 0 0 #EEEEEE;
    float: left;
    height: 200px;
    margin: 10px;
    width: 200px;
}

 

p.s. I ones wrote a litle article on this, you might want to check it out

Link to comment
Share on other sites

It worked thanks but if you take another look the pagination number is in the upper right conner of the screen. I need it to be in the lover left side of the screen

Don't keep adding things to the threads wish list, it makes them long and chaotic. The threads question is answered and solved.

 

To give a brief answer to your last question. The properties involved in positioning are Float, and the positions relative and absolute Google those bold words for tutorials or get a decent book. We are not here to write your code we are here to assist with your code (your efforts).

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.