View Full Version : Dreamweaver recordset repeat columns
unchew
December 19th, 2005, 01:59 PM
Hi,
I'm quite new with this thing of mySQL in dreamweaver 8. I have achieved to use the repeat option in a table... but only with one column. I was wondering if it is possible to get data from mySQL and display it in a table of 5 columns with repeating regions downwards. For example like Google Images, they don't have only one column of images in their results, they have like 5 columns of thumbnails. I would really appreciate some help... Thanks.
thomjjames
December 19th, 2005, 05:36 PM
think i've understood what you want correctly; i didn't find a solution for dreamweaver , but i've got some hand written PHP that will do it.
This is set for 3 cols [i think], should be able to develop it further to what you need [hopefully].
<?php // Set $i to 0
$i=0;
// Set number of columns
$num=3;
// Get info from database
$query = "SELECT * FROM table LIMIT 9"; $result = mysql_query($query) or die ("Couldn't execute query.");
// Start table HTML code
echo "<table width='500' border='0' bordercolor='#000000' cellspacing='4' cellpadding='4'>";
//Populate cells and change strings to whatever you want
while($row=mysql_fetch_array($result)){
$cat_id =$row["cat_id"]; $parent=$row["parent"]; $category=$row["category"]; $image=$row["image"]; $roll_image=$row["roll_image"]; $link=$row["link"];
if ($i==0) { echo "<tr width='95%'>";
} if ( ($i>0) && ( $i%$num==0) ) {
echo "</tr><tr width='95%'>";
} extract($row);
//choose which result strings you want to echo to
//the page and format them in a table row
echo "<td align='center' class='contact'><img name='category' src='$image' width='120' alt='category picture'></br><ahref='products.php?ID=&category=$category'>$category</a></td>";
$i++; }
// Tidy up table code
while ($i % $num) { echo "<td></td>"; $i++; }
//End table code
echo "</tr></table>"; ?>
hope that helps,
this site of mine uses the above code:
designers.jotodistributions.com/search.php (http://designers.jotodistributions.com/search.php)
TOM
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.