Forum Moderators: coopster
I am having problems pulling a URL from a database and making it clickable.
I need to be able to transfer a product name and price from a PHP page into Mals Shopping Cart
The URL is in the format similar to
"http://www.cartaddress.com/cf/add.cfm?userid=xxxxxxx&product=$row_rs_recordset['p20']&price$row_rs_recordset['pr20']"
I can only get it to display as above?
Its been doing my head in all day :(
If anyone can point me in the right direction I would be very gratefull.
Thanks
Karl
This way with the single quote you don't have to worry about escaping all the special characters.
I have been working through a tutorial that is very old and very short and lacks a full explanation, the example given to use is :
ht*tp://ww3.shoppingcart.com/cf/add.cfm?userid=username&
product=$item&price=$price&return=www.yourdomain.com\
but when I put this directly in the database and query it, all I get displayed on the page is the above, when it is supposed to be a link to add the product to the cart.
Thanks
Karl
$userid would be either the username or userid from the cookie/cart/session. How you get the value depends on where it is stored.
$row_rs_recordset would be the row returned from a function such as mysql_fetch_array [ca.php.net]
p20 is the product column from the db
pr20 is the price column from the db
Thanks for that :)
"Just for clarification... I read it that the Mals Shopping Cart is in Cold Fusion and you're making a php page to administer the addition of new products."
Mals cart is in coldfusion, what I am doing is pulling items from a databse and then adding them to Mals cart from a php page with a link like the one I am trying to make
jatar_k
$userid
Is me, this value does not change it always remains the same
$row_rs_recordset
Is the database table I am pulling from
p20 is the product column from the db
pr20 is the price column from the db
Exactly :)
Thanks
Karl
I'm not sure what you're code looks like but I'd do something like this...
$url = 'http://www.cartaddress.com/cf/add.cfm?userid=' . $userid . '&product=' . $row_rs_recordset['p20'] . '&price=' . $row_rs_recordset['pr20']
Another way that also works when you're dealing with array values would be:
$url = "http://www.cartaddress.com/cf/add.cfm?userid={$userid}\
&product={$row_rs_recordset['p20']}&price={$row_rs_recordset['pr20']}";
The curly brackets force interpolation even though the square brackets and quotes in your array references would otherwise be interpretted as the end of the variable name. Sometimes, I find this much more readable than a long series of concatenations.
Then you can just make the link with something like
echo "<a href=\"{$url}\">{$url}</a>";
Unless, of course, I'm mis-understanding the problem. That's a distinct possibility.
[edited by: dingman at 6:26 pm (utc) on June 26, 2003]
mysql_select_db($database_connglobal, $connglobal);
$query_rs_timax = sprintf("SELECT * FROM timax_catalogue WHERE model LIKE '%%%s%%' AND make LIKE '%%%s%%' ORDER BY timax_catalogue.model", $txtmodel_rs_timax,$txtmake_rs_timax);
$query_limit_rs_timax = sprintf("%s LIMIT %d, %d", $query_rs_timax, $startRow_rs_timax, $maxRows_rs_timax);
$rs_timax = mysql_query($query_limit_rs_timax, $connglobal) or die(mysql_error());
$row_rs_timax = mysql_fetch_assoc($rs_timax);
Does this help? :)
Thanks
Karl
(getting a strong feeling I may be ribbed for using DWMX :))
so, to use dingman's style, he has much more class than DWMX :)
$url="http://www.cart.com/cf/add.cfm?userid={$userid}&product={$row_rs_timax['p20']}&price={$row_rs_timax['pr20']}";
where $userid would be your userid taken from a config file or written explicitly.
echo "<a href=\"{$url}\">Anchor Text here</a>";
You could echo the product name where it says "Anchor Text here". I think that is right.