pavelazad Posted September 8, 2011 Share Posted September 8, 2011 hello all, I am using the following code to retrieve mysql data and show on my page.. <?php include "dbconnect.php"; $link=dbconnect(); $result = mysql_query("SELECT * FROM playlist where date= '2011-09-06'") or die(mysql_error()); echo "<table width = 100% border = '0' cellspacing = '2' cellpadding = '0'>"; while ($friendList = mysql_fetch_array($result)) { echo "<tr>" . "<td><a href='memberindex.php?id = ".$friendList['id']."'><img src='".$friendList['image']."' title='".$friendList['artist']."' alt='".$friendList['album']."'/><br />".$friendList['album']."</a><br /></td> " . "</tr> "; } echo "</table> "; ?> this code retrieve image and album name from the table and display as below: id 1 image1 album1 id 2 image2 album2 id 3 image3 album3 but i want to display the info as below: id1-----------------id2---------------id3 image1------------image2-----------image3 album1------------album2-----------album3 i want image and album name of a product as column but other product as rows. I hope you understand. anyone can help me with this please? Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/ Share on other sites More sharing options...
jasonc Posted September 8, 2011 Share Posted September 8, 2011 something like this... <style type="text/css"> .leftFloater { float: left; padding: 5px; } .clearFloater { clear: all; } </style> <?php include "dbconnect.php"; $link=dbconnect(); $result = mysql_query("SELECT * FROM playlist where date= '2011-09-06'") or die(mysql_error()); while ($friendList = mysql_fetch_array($result)) { ?> <div class="leftFloater"> <a href='memberindex.php?id=<? echo $friendList['id']; ?>'><img src='<? echo $friendList['image']; ?>' title='<? echo $friendList['artist']; ?>' alt='<? echo $friendList['album']; ?>'/><br /><? echo $friendList['album']; ?></a> </div> <?php } ?> <br class="clearFloater"> Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/#findComment-1267052 Share on other sites More sharing options...
pavelazad Posted September 8, 2011 Author Share Posted September 8, 2011 something like this... <style type="text/css"> .leftFloater { float: left; } .clearFloater { clear: all; } </style> <div style="leftFloater">column 1</div> <div style="leftFloater">column 2</div> <div style="leftFloater">column 3</div> <br style="clearFloater"> hi jasonc thanks for your reply. i am not sure how and where to use your code. can u pls help me a bit more if possible. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/#findComment-1267056 Share on other sites More sharing options...
jasonc Posted September 8, 2011 Share Posted September 8, 2011 just edited my post, but noticed a few things that may cause problems, maybe not but will submit another version of the code <style type="text/css"> .leftFloater { float: left; padding: 5px; } .clearFloater { clear: all; } </style> <?php include "dbconnect.php"; $link=dbconnect(); $result = mysql_query("SELECT * FROM playlist where date= '2011-09-06'") or die(mysql_error()); while ($friendList = mysql_fetch_array($result)) { ?> <div class="leftFloater"><a href='memberindex.php?id=<?php echo $friendList['id']; ?>'><img src='<?php echo $friendList['image']; ?>' title='<?php echo $friendList['artist']; ?>' alt='<?php echo $friendList['album']; ?>'/><br /><?php echo $friendList['album']; ?></a></div> <?php } ?><br class="clearFloater"> Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/#findComment-1267058 Share on other sites More sharing options...
jasonc Posted September 8, 2011 Share Posted September 8, 2011 <!-- please the code below within your <head> tag --> <style type="text/css"> .leftFloater { float: left; padding: 5px; } .clearFloater { clear: all; } </style> <!-- then replace your code you provided in your original post with the code below --> <?php include "dbconnect.php"; $link=dbconnect(); $result = mysql_query("SELECT * FROM playlist where date= '2011-09-06'") or die(mysql_error()); while ($friendList = mysql_fetch_array($result)) { ?> <div class="leftFloater"><a href="memberindex.php?id=<?php echo $friendList['id']; ?>"><img src="<?php echo $friendList['image']; ?>" title="<?php echo $friendList['artist']; ?>" alt="<?php echo $friendList['album']; ?>" /><br /><?php echo $friendList['album']; ?></a></div> <?php } ?><br class="clearFloater"> Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/#findComment-1267063 Share on other sites More sharing options...
jamesxg1 Posted September 8, 2011 Share Posted September 8, 2011 Take a look at this... http://www.w3schools.com/html/html_tables.asp James. Quote Link to comment https://forums.phpfreaks.com/topic/246729-php-mysql-query-display-help-need/#findComment-1267070 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.