Jump to content

Recommended Posts

Hey guys,

 

I have a query where I'm taking out only 4 rows of data.

 

Now, my question is. How can I display each row in a different place on the page?

 

For example:

 

Row 1 - top left corner

Row 2 - top right corner

Row 3 - bottom left corner

Row 4 - bottom right corner

 

Help???

Shows 4 Columns:

$sql = mysql_query("SELECT * FROM tbl_name");
$row = mysql_fetch_array($sql);    // Creates Array For You!

echo '<p>'.$row['column1'].'</p>';
echo '<p>'.$row['column2'].'</p>';
echo '<p>'.$row['column3'].'</p>';
echo '<p>'.$row['column4'].'</p>';

 

Shows 4 Rows:

$sql = mysql_query("SELECT * FROM tbl_name LIMIT 4");
while($row = mysql_fetch_array($sql)){    // Creates Array For You!
     echo '<p>'.$row['column1'].'</p>';
}

<?php
$rows = array();
$results = mysql_query('SELECT * FROM table');
while($values = mysql_fetch_array($results)){
     $rows[] = $values['column']; //put the query results in the array
}
//corner 1
echo $rows[0];
//corner 2
echo $rows[1];
//and so on
?>

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.