Hi All,
Hope all is well.
I have a question that relates to a puzzling piece of code. I have three tables with records in, all of these are needed. The tables are selecting the right records I just need to output them correctly. What I would like to do is from the one selected column is split the results over two HTML columns, I’ve created a while loop however whilst it’s outputting the information it is not splitting the data over two columns
.
Please see below for the code:
<?php
$queryb = mysql_query("SELECT option_value_description.name, option_value_description.option_value_id, product_option_value.option_value_id, product_option_value.ob_sku, product_option_value.price
FROM option_value_description, product_option_value WHERE option_value_description.option_value_id = product_option_value.option_value_id AND product_option_value.product_id='".$_GET['product_id']."'GROUP BY option_value_description.name") or die (mysql_error());
$querya = mysql_query("SELECT option_value_description.name AS optname, option_description.name, option_description.option_id, option_value_description.option_id, product_option_value.product_id
FROM option_description, option_value_description, product_option_value WHERE option_description.option_id = product_option_value.option_id AND product_option_value.product_id='".$_GET['product_id']."'GROUP BY option_description.option_id") or die (mysql_error());
$queryd = mysql_query("SELECT option_description.name, option_description.option_id, option_value_description.name AS opname, option_value_description.option_id, product_option_value.product_id
FROM option_description, option_value_description, product_option_value WHERE option_description.option_id = product_option_value.option_id AND product_option_value.product_id='".$_GET['product_id']."'ORDER BY option_value_description.option_id DESC") or die (mysql_error());
$numberresults = mysql_num_rows($queryb);
$halfresults = ($numberresults / 2);
$counter = 0;
echo '<table class="attribute">
<thead>
<tr>';
while ($row = mysql_fetch_array($querya)) {
echo '
<td>'.$row['name'].'</td>';
}
echo ' <td>'.$text_sku.'</td>
<td>'.$text_price.'</td>
</tr>
</thead>
';
while ($rowb = mysql_fetch_array($queryb) and $rowa = mysql_fetch_array($queryd)) {
$queryc = mysql_query("SELECT product.price FROM product WHERE product_id ='".$_GET['product_id']."'");
$rowc = mysql_fetch_array($queryc);
$total_price = $rowb['price'] + $rowc['price'];
number_format((float)$total_price, 2, '.', '');
echo '<tr>
<td>'.$rowb['name'].'</td>
<td>'.$rowb['name'].'</td>
<td>'.$rowb['name'].'</td>
<td>'.$rowb['ob_sku'].'</td>
<td>'.$total_price.'</td>
</tr>';
}
echo '
</table>
</div>';
?>
Any help would be great…