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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.