Jump to content

[SOLVED] Help organising a group of <?php echo functions within a page


Recommended Posts

Hi all,

 

I have a simple query where it fetches a profile with picture, name and an edit/delete option from a database.  But im having trouble styling them so they appear as this within a box.  Here is what they are displaying as:

 

 

[ ]

[ ]

[ ]

[ ]

[ ]

 

When in fact i want them to be side by side within a box like this:

 

[ ]  [ ]  [ ]  [ ] 

[ ]  [ ]  [ ]  [ ] 

[ ]  [ ]  [ ]  [ ] 

 

 

Here is the code at the moment

 

            <?php

include("../connect.php");

$query="SELECT * FROM artists ORDER BY artist_lastname";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();

if ($num > 0 ) {
$i=0;
while ($i < $num) {
$artist_firstname = mysql_result($result,$i,"artist_firstname");
$artist_lastname = mysql_result($result,$i,"artist_lastname");
$thumb_image_location = mysql_result($result,$i,"thumb_image_location");
$id = mysql_result($result,$i,"id");

?>


<?php echo "<a href=\"update.php?id=$id\"><div><image src='http://localhost/cms/artists/$thumb_image_location' height=115px width=90px style=''/></a>";
echo "<p align='center'><h3>$artist_firstname $artist_lastname</h3></p>";	
echo "<a href=\"update.php?id=$id\">Update</a>   -   <a href=\"delete.php?id=$id\">Delete</a>";

++$i; } } else { echo "The database is empty"; }?>

 

Does anybody know a good way of doing this please?  :confused:

 

Link to comment
https://forums.phpfreaks.com/topic/167390-solved-help-organising-a-group-of/
Share on other sites

Thanks for the reply, where abouts do I put the code in?

 

I have inserted it and get..

 

row: 0; col: 0 row: 0; col: 1 row: 0; col: 2 row: 0; col: 3 row: 1; col: 0 row: 1; col: 1 row: 1; col: 2 row: 1; col: 3 row: 2; col: 0 row: 2; col: 1 row: 2; col: 2 row: 2; col: 3 

 

Obviously it prints that but how do I get the data to adhere to the row&col function?

 

Thanks again  :)

 

Thanks for the reply, where abouts do I put the code in?

 

I have inserted it and get..

 

row: 0; col: 0 row: 0; col: 1 row: 0; col: 2 row: 0; col: 3 row: 1; col: 0 row: 1; col: 1 row: 1; col: 2 row: 1; col: 3 row: 2; col: 0 row: 2; col: 1 row: 2; col: 2 row: 2; col: 3 

 

Obviously it prints that but how do I get the data to adhere to the row&col function?

 

Thanks again  :)

 

 

Actually you get:

 

 

row: 0; col: 0
row: 0; col: 1
row: 0; col: 2
row: 0; col: 3
row: 1; col: 0
row: 1; col: 1
row: 1; col: 2
row: 1; col: 3
row: 2; col: 0
row: 2; col: 1
row: 2; col: 2
row: 2; col: 3

 

But only if you do "view source". Anyhow it just shows you the mechanism how one can create rows and cols. The first loop creates the rows, while the second loop creates the cols for a row. Use the faq snippet by crayon or ober as suggested by wildteen.

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.