Jump to content

Adding additional values to a variable


Recommended Posts

I'm trying to add some modifications to my phpBB site by getting information from a database on one of my other sites. It's pulling information correctly, but I'm having trouble adding more information to a variable. I actually so confused myself that it's going to be hard for me to explain this in propper terms.

Here is the code I have so far:

[code=php:0]$query1="SELECT * FROM xcart_products WHERE add_date < '$today_date' && add_date > '$minus_five_days'";
//echo $numrows1;
if ($numrows1 < 2)
$latest_prod = "Latest product: ";
$latest_prod = "Latest products: ";
$count = 0;
while ($count < $numrows1)
//echo $product." - ";
//The above variables will be included in: <a href="http://store.plastikracing.net/product.php? productid={PRODUCT_ID}" target="_blank">{PRODUCT}  <img src="http://store.plastikracing.net/product_images/t_{PRODUCT_ID}.jpg" width="50" height="38"></a><br>
} [/code]

Bascially, in that loop, there is a chance that "numrows1" is going to be greater than 1. Here is what I want to do. Let's say there is 1 row in the database that matches the criteria. The information pulled from that row will be inserted into a variable like so:

[code=php:0]$display_product = "<a href='http://store.plastikracing.net/product.php?productid=".$product_id." target='_blank'>".$product."<img src='http://store.plastikracing.net/product_images/t_".$product_id.".jpg' width='50' height='38'></a><br>";[/code]

Now, let's assume there are 2 products that match the criteria. I would like the 2nd product to be added to the end of the $display_product like so:

[code=php:0]$display_product = "<a href='http://store.plastikracing.net/product.php?productid=".$product_id[0]." target='_blank'>".$product[0]."<img src='http://store.plastikracing.net/product_images/t_".$product_id[0].".jpg' width='50' height='38'></a><br><a href='http://store.plastikracing.net/product.php?productid=".$product_id[1]." target='_blank'>".$product[1]."<img src='http://store.plastikracing.net/product_images/t_".$product_id[1].".jpg' width='50' height='38'></a><br>";[/code]

Does anyone have any suggestions? I was looking at using implode(), but I'm no too familiar with arrays.
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.

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.