help on loops...

i need to print a table where there should be 5 rows

and 3 columns(td)…

this has to done by loops…

can any one help me???

What do you have so far, and where do you get stuck?
Where does the script/output go wrong, or is it doing something that it’s not supposed to?

[code]<?php
mysql_select_db($database_conmyprice, $conmyprice);
$sql_qry=mysql_query(“SELECT * FROM items WHERE itemID=‘1000141’”);
$sql_arr=mysql_fetch_assoc($sql_qry) or die(mysql_error());

$get_IDs=explode(",",$sql_arr[‘txt_crosell’]);
$ii=sizeof($get_IDs);
$xx=0;

echo “

”;
foreach($get_IDs as $get_ID){
for ($i=1;$i<=$ii;$i++){
//echo $i." x". $xx."
";

if($xx==0 ){
echo “

”;
echo “”;
$xx=$xx+1;
}
else{
echo “”;
$xx=$xx+1;
if ($xx==3){
echo “”;
$xx=0;
}
}
}
}
echo “
$get_ID$get_ID
”;
?>
[/code]

Here size of the array is 6, now i want get printed first 3 elements of the array to first row with 3 columns and next 3 elements of the array to next row and so on…[/code]

something like in http://www.techstore.co.uk

Here’s some pseudo-code on what you want to do:

<table>
- loop through items
-- if first column in row, <tr>
- print item
-- if last/third column in row, </tr>
- end loop
</table>

Thanks for the reply…

i had done it myself…

anyway thanks again

Sponsor our Newsletter | Privacy Policy | Terms of Service