Hi, i wanna select some details from db and i wrote select query and i punted it in the while but, i wanna show the details in the columns instead of rows
is there any body to help me ????

$brush_price = 5; 
$counter = 10;

echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Quantity</th>";
echo "<th>Price</th></tr>";
while ( $counter <= 100 ) {
	echo "<tr><td>";
	echo $counter;
	echo "</td><td>";
	echo $brush_price * $counter;
	echo "</td></tr>";
	$counter = $counter + 10;
}
echo "</table>";

Quantity Price
10 50
20 100
30 150
40 200
50 250
60 300
70 350
80 400
90 450
100 500

Recommended Answers

All 3 Replies

One way of doing it:

$brush_price = 5;
$counter = 10;

// row for quantities with heading in first cell
$qtyRow = '<tr><th>Quantity</th>';

// row for prices with heading in first cell
$priceRow = '<tr><th>Price</th>';

// add cells to each row
while ( $counter <= 100 ) {

    $qtyRow .= "<td>$counter</td>";

    $priceRow .= "<td>" . ($brush_price * $counter) . "</td>";

    $counter = $counter + 10;
}

// end of the rows
$qtyRow .= '</tr>';
$priceRow .= '</tr>';

// echo the table
echo "<table border=\"1\" align=\"center\">";
echo $qtyRow;
echo $priceRow;
echo "</table>";

Thanks Man

Glad it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.