Jump to content

Display Data in Dynamic List


Pavlos1316

Recommended Posts

Hello,

 

This the dynamic list code that I use to display data from my db:

$dynamicListBody = "";
$sql = mysql_query("SELECT * FROM products WHERE category='Body' ORDER BY id ASC");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
             $id = $row["id"];
     $product_name = $row["product_name"];
     $details = $row["details"];
     $price = $row["price"];
     $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
     $dynamicListBody .= '
     <table width="95%">
              <tr>
               <td width="10%">
	<img style="border:#666 1px solid;" src="../stock_photos/' . $id . '.png" alt="' . $product_name . '" />
       </td>
               <td width="35%">
        <span class=itmttl>' . $product_name . '</span>
	<br />
                <span class=text>' . $details . '
                <br />
                €' . $price . '</span>
	<br />
                <form id="bd_itm1" name="bd_itm1" method="post" action="help_scripts/cart_functions.php">
                <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
                <input type="submit" name="button" id="button" value="Add to Cart" />
                </form>
       </td>
       <td width="5%">
       </td>
       <td width="10%">
       </td>
       <td width="35%">
	<br />
	<form id="bd_itm1" name="bd_itm1" method="post" action="help_scripts/cart_functions.php">
                <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
                <input type="submit" name="button" id="button" value="Add to Cart" />
                </form>
       </td>
              </tr>
             </table>';
    }

It puts my data only on the left column like

1 aaa

2 bbb

3 ccc

What should I add to make it inserting data into my 2nd column on the row like: (?)

1 aaa | 2 bbb

3 ccc | 4 ddd

5 eee |...

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/237195-display-data-in-dynamic-list/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.