Log in

View Full Version : php and html



hemi
09-14-2009, 09:55 AM
<div id='sss' class='col'>
<h4>for sale</h4>
<div class='cats'> <div class='cats'><ul id='ccc1'>
";
$res=mysql_query("select * from post_subtypes where postid=16");

while($var=mysql_fetch_array($res))

{

echo"<li><a href=sale1.php?id=$var[cid]><font size=2> $var[name]</font></a></li>";
}
echo"</ul>
</div>
</div>
------------------------------------------------------------------------
when i do this i will get my required values in a single row. what I want is to get them in two rows (half in one row and the other half in another row)

any suggestions plz

JShor
09-14-2009, 11:55 PM
I did this the other day. Thing is I used it for an array, not a mysql db, but I changed it for mysql, hopefully this'll work. Here you go:



<div id='sss' class='col'>
<h4>for sale</h4>
<div class='cats'> <div class='cats'><ul id='ccc1'>
<?php

echo '<table border="0" cellspacing="10" cellpadding="0" align="center">';

function print_data($rows, $cols, $offset) {
if($rows > 0) {

$res = mysql_query("select * from post_subtypes where postid=16 LIMIT $offset,$rows");
$offset = $offset + $cols;

echo "
<tr>";
while($var = mysql_fetch_array( $res )) {
echo '
<td>
<li><a href="sale1.php?id='.$var[cid].'"><font size="2">'.$var[name].'</font></a></li>
</td>';
}
echo "
</tr>";
$rows = $rows - 1;
print_data($rows, $cols, $offset);
}
}
echo"</ul>";

$rows = 5000; //rows to display
$cols = 2; //columns to display
$offset = 0; // offset, good for paging

print_data($rows, $cols, $offset);
echo "</table>";

?>
</div>
</div>


HTH:)

hemi
09-15-2009, 05:36 AM
thnks it is working