a big hi to all the developers out there...

first of all take a look at this static html
http://www.lootah.com/arabictutor/4english/sentences/s01.htm this is the wanted format.

i've gone throug many alternateing scripts, unfortunatlly, i couldnt find that match my requirement.

what im tryin to present the result in something like this


|catid:1 |catid:2 |catid:3 |
|catnm |catnm |catnm |
|imgpath|imgpath|imgpath|


|catid:4 |catid:5 |catid:6 |
|catnm |catnm |catnm |
|imgpath|imgpath|imgpath|


|catid:7 |catid:8 |catid:9 |
|catnm |catnm |catnm |
|imgpath|imgpath|imgpath|

and so on

with the below script im able to get something like this:-

|catid:1 |catid:2 |catid:3 |
|catid:4 |catid:5 |catid:6 |
|catid:7 |catid:8 |catid:9 |

<table border="0" width="100%">
<tr>
<?
$rw = 3;//number of columns per row
$cnt = 0;
while ($result=mysql_fetch_array($query))
{
    $cnt = $cnt + 1;
    # Your results layout goes here
	$catid=$result[0];//cat Id
	$catprntid=$result[1];//parent id
	$catnm=$result[2];//name
	$cattitle=$result[3];//title
	$imgpath=$result[4];//img src

echo "<td vAlign=top align=middle bgColor=#dbdce9>
<a href=alphabets.php?catprntid=$catid><img src=$imgpath></a></td>";

if ( $cnt >= $rw ){
    print("</tr>");
    $cnt = 0;
}
}
?>
</tr>
</table>

    Although this is perhaps not as glamerous a solution as the previous suggestion, you could simply use a table-within-table setup.

    For example, in the main table, each cell is for the corresponding catid. In each cell, create a separate, 3 row table containing the necessary info.

    <table border="0" width="100%"> 
    <? 
    $rw = 3;//number of columns per row 
    $cnt = 0; 
    while ($result=mysql_fetch_array($query)) 
    { 
        if ($cnt == 0)
            echo "<tr>";
        $cnt++; 
        # Your results layout goes here 
        $catid=$result[0];//cat Id 
        $catprntid=$result[1];//parent id 
        $catnm=$result[2];//name 
        $cattitle=$result[3];//title 
        $imgpath=$result[4];//img src 
    
    echo "<td>";
    // interior table
        echo "<table>";
        echo "<tr><td vAlign=top align=middle bgColor=#dbdce9> 
        <a href=alphabets.php?catprntid=$catid><img src=$imgpath></a></td></tr>";
        echo "<tr><td>$catnm</td></tr>";
        echo "<tr><td>$imgpath</td></tr>";
        echo "</tr></table>";
    // end interior table
        echo "</td>";
    
    if ( $cnt >= $rw ){ 
        print("</tr>"); 
        $cnt = 0; 
    } 
    } 
    ?> 
    </tr> 
    </table> 

      it worked .. just perfect ....& its as simple as it is ...

      thanks for the very great help..

      now i can streach my hans on my <table> 😉

      i new i was never mistaken whome to ask!

      you've made my day... thanks once again..

        Write a Reply...