homepage Welcome to WebmasterWorld Guest from 23.22.128.96
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Changing rows to columns
rcull




msg:4680053
 6:18 pm on Jun 15, 2014 (gmt 0)

I had a young fellow who wrote me a simple database query. He is long gone:(

I would like to change it and have been trying, but it is just over my head. So if there is someone with a few minutes who would do it for me, it would be appreciated. What I want is right now, it presents itself with 4 data cells in one row. I would like it to present itself in 4 rows with one data cell.

<html>
<head>
<title> Ads </title>
</head>
<body bgcolor="#C0C0C0" text="#000000" alink="#FF0000" vlink="#FF00FF" link="#0000FF">

<div align="center">
<table class="alt1" border="5" bgcolor="fffceb" cellpadding="6" cellspacing="1" width="100%">
<tr><td colspan="4"><u>WANTED ADS</u> in the <i>Team Classifieds</i>...</td></tr>
<tr>
<?php
$mysql_link = mysql_connect("localhost", "teXXXXXX_root", "XXXXXXXX");
mysql_select_db ("teXXXXXX_forums");
if(!$mysql_link){
print("Did not connect to database<br>");
exit;
}
function cl_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}

$result = mysql_query('SELECT p.id, p.cat, p.user, p.userid, p.bigimage, p.title FROM ppc_products p WHERE p.cat=\'58\' OR p.cat=\'59\' OR p.cat=\'60\' OR p.cat=\'61\' OR p.cat=\'62\' ORDER BY RAND() DESC LIMIT 0, 4');
while($row = mysql_fetch_array($result,MYSQL_NUM))
{
$photo = $row[4];
$photolen = strlen($photo);
$theext = cl_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );

echo ' <td width="25%"><center><a href=http://www.teXXXXXX.com/classifieds/showproduct.php?product='.$row[0].'>'.
'<br>'.$row[5].
'</a><br><b>'.$row[2].'</b><br></center></td>
';
}

?>
</tr>
</table>
</div>
<br />
</body>
</html>

Thanks!

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved