littlevisuals Posted July 25, 2009 Share Posted July 25, 2009 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? Quote Link to comment Share on other sites More sharing options...
ignace Posted July 25, 2009 Share Posted July 25, 2009 $rows = 3; $cols = 4; for ($i = 0; $i < $rows; ++$i) { for ($j = 0; $j < $cols; ++$j) { print "row: $i; col: $j" . PHP_EOL; } } Quote Link to comment Share on other sites More sharing options...
littlevisuals Posted July 25, 2009 Author Share Posted July 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 25, 2009 Share Posted July 25, 2009 You cant position your text with PHP. You need to use HTML/CSS. Check out this FAQ snippet to achieve this. Quote Link to comment Share on other sites More sharing options...
littlevisuals Posted July 25, 2009 Author Share Posted July 25, 2009 Wow thanks Quote Link to comment Share on other sites More sharing options...
ignace Posted July 26, 2009 Share Posted July 26, 2009 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. Quote Link to comment 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.