Jump to content

[SOLVED] Displaying data in different places!


budimir

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
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.