Jump to content

php mysql query display help need..


pavelazad
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<!-- 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">

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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