budimir Posted August 23, 2008 Share Posted August 23, 2008 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??? Quote Link to comment https://forums.phpfreaks.com/topic/121009-solved-displaying-data-in-different-places/ Share on other sites More sharing options...
The Little Guy Posted August 23, 2008 Share Posted August 23, 2008 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>'; } Quote Link to comment https://forums.phpfreaks.com/topic/121009-solved-displaying-data-in-different-places/#findComment-623787 Share on other sites More sharing options...
Fadion Posted August 23, 2008 Share Posted August 23, 2008 <?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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/121009-solved-displaying-data-in-different-places/#findComment-623791 Share on other sites More sharing options...
budimir Posted August 23, 2008 Author Share Posted August 23, 2008 You rock guys!!!!!!!!!!!!!!!!! Awesome!!! Quote Link to comment https://forums.phpfreaks.com/topic/121009-solved-displaying-data-in-different-places/#findComment-623796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.