I'm stumped.
Here's what I need to happen:
I have several pages containing fifteen thumbnail pics each. Clicking on a thumbnail takes a customer to a full page describing the item, and has buttons for adding to cart & viewing cart contents.
If an item sells, the shopping cart service (Mal's) sends a remote call, that populates my db (that part works). That's the only function for the table.
SO, I need to write a script that will intervene when the thumbnail pic is clicked. The script will query the database to see if any number contained in the field “cart” (always four alphanumerics - x + three numbers [e.g. x123, x004, x999]) = the item number of the piece the person is trying to view.
If they’re equal, the browser is either redirected to a canned “sold” page – or (better still) the thumbnail pic changes to a pic that reads “sold”.
If ? then the browser proceeds on to the item description page.
When I have an opportunity, I then go in and manually clear the db row. Once I’ve replaced a sold item with another.
The main problem is that I'm locked into populating my db table from a remote call that I can't configure.
Only the fields “cart” contains multiple values. The values in the field "cart" are delimited by colons. If one person purchases two or more items, each item is further delimited by a tilde. The values correspond with “description, quantity, price, shipping units, stock code”
So the “cart” field for two items sold could look like:
description1 : 1 : 15.50 : 1 : x003~ description2 : 1 : 12.95 : 1 : x136
all I need are the values “x###“ for each “cart” field in every row.
just in case it’s relevant, here’s the working script that populates the db.
<?PHP
include("config.php");
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database $DBName");
mysql_select_db($DBName) or die("Unable to select database $DBName");
$order_date=time("m j y h:i");
mysql_query("REPLACE INTO orders (username,id,ip,date,method,cart,discount,subtotal,shipping,tax,total,inv_name,inv_company,inv_addr1,inv_addr2,inv_state,inv_zip,inv_country,tel,email,message)
VALUES ('$username',$id,'$ip','$order_date','$method','$cart','$discount','$subtotal','$shipping','$tax','$total','$inv_name','$inv_company','$inv_addr1','$inv_addr2','$inv_state','$inv_zip','$inv_country','$tel','$email','$message')");
?>
Any ideas at all on how to get this all to come together?
Am I going about this all wrong?