PDA

View Full Version : (Tables) Coding Help



Mr-Trainor
09-12-2009, 06:35 PM
Hey,
if you look at:
http://www.clubpixels.co.uk/test
you will see what's wrong. I have the correct amount of columns but now I need the items to automatically go accross and then start a new row for every 6 cells used. I've been told to use 'nested loops' but after searching that on Google, it doesn't seem to help me very much! All help is appreciated and the code at the moment is:


<?php
include("config.php");
include("opendb.php");
$get_cats = mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`") or die(mysql_error());
$get_info = mysql_query("SELECT * FROM `systeminfo`") or die(mysql_error());
$info = mysql_fetch_array($get_info);
while($cats = mysql_fetch_array($get_cats)) {
$get_rares = mysql_query("SELECT * FROM `rares` WHERE `catid`='".$cats['id']."'") or die(mysql_error());
echo("<h2>".$cats['name']."</h2><br>

<center>
<table width=\"90%\" border=\"0\">
");
$color1 = $info[stripe1];
$color2 = $info[stripe2];
$row_count = 0;
while($rare = mysql_fetch_array($get_rares)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><img alt="" src="<?php echo("".$info."".$rare['image'].""); ?>" onmouseover="Tip('<b><?php echo $rare['name']; ?></b>.<br><i>Last Updated: <?php echo $rare['lastedited']; ?></i>')" onmouseout="UnTip()"><br><?php echo $rare['value']; ?> CS</td>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"></td>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"></td>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"></td>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"></td>

<td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"></td>

</tr>
<?php
$row_count++;
}
echo("</table>
</center><br>

");
}
?>
[I]All help is greatly appreciated and will give +rep to any helpful information :P

ams30
09-12-2009, 06:50 PM
The answer lies in CSS ;)

UrbanRyan
09-12-2009, 07:09 PM
use css xD

Mr-Trainor
09-12-2009, 07:30 PM
Thanks for the help, +rep.
I've never made my own CSS document though, any help? ;)

Mr-Trainor
10-12-2009, 03:59 PM
Thanks for the help, +rep.
I've never made my own CSS document though, any help? ;)

Rephrase that. I HAVE made many css documents in the past, althought not multiple column ones. Once I make it css though, how do I get the rares to show up in each box instead of being like a list and showing 1 per row?

Mr-Trainor
10-12-2009, 09:13 PM
All is now sorted!
http://clubpixels.co.uk/mr-trainor/TwistedValues/show_raresTEST2.php
Thanks to all who helped :D

Want to hide these adverts? Register an account for free!