I'm experimenting with php and mysql. I have table in mySQL database something like:
| sr.no| name |
| 1 | abc |
| 2 | xyz |
| 3 | zxc |
Now i see the table in vertical for serial number and name. But if i have to display them in horizontal way. How to do that ?
like |sr no| 1 |2 |3 | 4|
|name| abc|
how to do this using php and mysql ?
| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Displaying Rows & Columns Horizontaly
Started by mahesh2k, Feb 07 2010 11:10 AM
5 replies to this topic
#4
Posted 07 February 2010 - 08:09 PM
mahesh2k, on Feb 7 2010, 11:50 AM, said:
i want to display it on webpage. is it possible to display it that way ?
#5
Posted 08 February 2010 - 03:16 AM
If I am thinking properly, this'll work, just mod it to your own database and mod the table configuration and whatnot. This uses L1 and L2 classes, which are alternating colors. You can do with it what you like. But, it NEEDS the "while" function.
<? if ($_GET[XX] == ""){
echo('<tr>
<td width=10% class=headersmall></td>
<td width=12% align=left class=headersmall>XX</td>
<td width=4% align=left class=headersmall></td>
<td width=11% align=left class=headersmall>XX</td>
<td width=14% align=left class=headersmall></td>
</tr>');
$result = mysql_query("SELECT * FROM `XX`");
$i = 0;
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if($line['id'] == '1'){$XX_name = XX; $XX= '1';}
if($line['id'] == '2'){$XX_name = XX; $XX= '2';}
if($i%2 == 0)
{
echo "<tr>
<td width=10% class=L1></td>
<td width=12% align=left class=L1>".$XX."</td>
<td width=4% align=left class=L1></td>
<td width=11% align=left class=L1><a class=link href=XX.php?tech=".$XX."'>XX</a></td>
<td width=14% align=left class=L1></td>
</tr>";
$i++;
}
else
{
echo "<tr>
<td width=10% class=L2></td>
<td width=12% align=left class=L2>".$XX."</td>
<td width=4% align=left class=L2></td>
<td width=11% align=left class=L2><a class=link href='XX.php?XX=".$techAbbr."'>XX</a></td>
<td width=14% align=left class=L2></td>
</tr>";
$i++;
}
}
}?>
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users















