Log in

View Full Version : having problems creating columns in PHP and CSS



RadBids.net
12-22-2015, 12:01 AM
Hi,

Hope someone can guide me here. Using PHP and CSS to format dynamic columns. PHP extracts the data correctly into HTML, but cannot get CSS to format the Columns correctly, See uploaded jpg file. The following is the PHP code:

Thanks for your help

Mandy



function key_navigation ($products_array, $cpd_array) {
$product_set = find_all_products(false);
$output = "<table width='100%'> ";

while($product = mysqli_fetch_assoc($product_set)) {

if ($products_array && $product["p_id"] == $products_array["p_id"]) {
}
$num = $product["p_id"];
$i = 0;
$output .= "<th bgcolor=\"#993366\" valign=\"middle\" width=\"10%\"> <a href=\"edit_product.php?p_id=";
$output .= urlencode($product["p_id"]);
$output .= "\">" ;
$output .= htmlentities($product["p_desc"]);
$output .= "</a>";
$cpd_set = find_page_for_cpd ($product["p_id"]);
$output .= "</th>";
//$output .= "<tr> </tr>";
while($cpd = mysqli_fetch_assoc($cpd_set)) {

if ($cpd_array && $cpd["cpd_id"] == $cpd_array["cpd_id"]) {
}


//$output .= "<tr>";
$output .= "<td align='center'>";

$output .= "\"<a href=\"edit_cpd.php?cpd_id=";
$output .= urlencode($cpd["cpd_id"]);
$output .= "\">";
$output .= htmlentities($cpd["cpd_title"]);

$output .= "</td>";
}
}
mysqli_free_result($product_set);
$output .= "</table>";

return $output;
}

Beverleyh
12-22-2015, 07:18 AM
Unfortunately we can't troubleshoot an image. If you need CSS help, we need to see a sample of the HTML and the CSS that applies to it.

However, this currently doesn't look to be CSS related at all - rather an issue with the output of the HTML that the PHP is generating. Unfortunately, I don't understand the groupings of the items named in your image and the text in the top image bears no relation to that in the lower image so I don't really want to make a guess. The PHP also looks incomplete.

Check the source code to see what HTML is being generated and then modify the PHP and check the HTML output again. Repeat. What you're trying to do might work if you start a table right before each purple header, and then close it right after the last product in that grouping. Then you could float the small group tables next to each other. If you want to try that, the HTML output you'd be aiming for would be something like this for each grouping;
<table>
<tr><th>header</th></tr>
<tr><td>item 1</td></tr>
<tr><td>item 2</td></tr>
<tr><td>item 3</td></tr>
</table>