Hi,
I wanted to display data which is in my db.The format of displaying must be in a div, in that div 3 columns & each column must have 10 rows.Am using this:

while($data = mysql_fetch_array($result)) { 
    echo $query;
    echo ' <tr> <td colspan="3" > <a href="'.$data['MedName'].'" >' . $data['dispname'].' </a> </td>'; 
    echo'</tr>'; 
}

which is displaying it in a single line. I used even for loop which is displaying again in the single line.What way can be used to print in the above format?

here is something i typed up a few weeks ago. it should work.

$table = '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';

$cols = 3;
$per_column = 10;
$col = 1;
$table .= '<tr>';
$table .= '<td>';
$table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
$i = 0;
while ($row = $p->fetchAssoc($query)) {
	$table .= '<tr>';
	$table .= '<td><a href="' . $row['MedName'] . '">' . $row['dispname'] . '</a></td>';
	$table .= '</tr>';
	if ($i == ($per_column*$col)) {
		$table .= '</table>';
		$table .= '</td>';
		$table .= '<td>';
		$table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
	$col++;
	}
$i++;
}
$table .= '</table>';
$table .= '</td>';
$table .= '</tr>';
$table .= '</table>';

echo $table;

Its Working.But have small problem, I have 4 buttons Home Categories Brand Store in a row.When I click each button the text display.Here if catogery is clicked that is in the same row but remaining 3 buttons are moving down.when it is clicked again..they are going back to normal position.Why is it like that?

This article has been dead for over six months. Start a new discussion instead.