| | |
Paypal shopping basket link
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2004
Posts: 6
Reputation:
Solved Threads: 0
Am new to SQL and PHP. Only been using them for about 3 weeks to create an e-commerce site for some friends. I have been trying to set up a link to paypal's shopping basket feature from my listing page. I'm trying to get the link to appear next to each row in my listing so that it extracts the rows values and sends them through to the shopping basket. Here is the script for the page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<HTML><HEAD>
<TITLE></title>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="website/Page1_files/page.css" rel=stylesheet>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META http-equiv=Last-Modified content=22/05/2004:08:35:13>
<META http-equiv=Pragma content=no-cache></HEAD>
<BODY>
<div align="center">
<center>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse; font-family:Arial Black; color:#FFFFFF; text-align:center" bordercolor="#000000" width="80%" id="AutoNumber1" bgcolor="#003163">
<tr>
<td width="100%" colspan="8" align="center" valign="top" height="1" bgcolor="#FFFFFF">
<img border="0" src="headlight_protectors_files/Alfa_romeo_Logo.jpg"></td>
</tr>
<tr>
<td width="100%" height="24" align="center" colspan="8" bgcolor="#000000">
<font face="Arial Black" size="4" color="#FFFFFF">Headlight Protectors</font></td>
</tr>
<tr>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Part Number</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Make</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Model</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<p align="center"><font face="Arial Black" color="#FFFFFF">Year Range</font></td>
<td width="23%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Description</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Price</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Shipping Cost</font></td>
<td width="5%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
</td>
</tr>
<tr>
<?php
$db = mysql_connect("HOST_NAME","DB_NAME","DB_PASSWORD");
mysql_select_db("DB_NAME",$db);
$result = mysql_query("SELECT * FROM Items WHERE Category=35",$db);
while ($myrow = mysql_fetch_row($result)) (
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[7], $mysql[8]));
echo "</table>\n";
?>
</tr>
</table>
</div>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/view_cart_02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
</form>
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<p> </p>
</BODY></HTML>
and here is the script for the paypal link:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="hidden" name="item_name" value="ITEM_NAME_FROM_DB">
<input type="hidden" name="item_number" value="ITEM_NUMBER_FROM_DB">
<input type="hidden" name="amount" value="COST_FROM_DB">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
</form>
Please could someone help me with this as I have run out of ideas.
Thanks
Huw
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<HTML><HEAD>
<TITLE></title>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="website/Page1_files/page.css" rel=stylesheet>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META http-equiv=Last-Modified content=22/05/2004:08:35:13>
<META http-equiv=Pragma content=no-cache></HEAD>
<BODY>
<div align="center">
<center>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse; font-family:Arial Black; color:#FFFFFF; text-align:center" bordercolor="#000000" width="80%" id="AutoNumber1" bgcolor="#003163">
<tr>
<td width="100%" colspan="8" align="center" valign="top" height="1" bgcolor="#FFFFFF">
<img border="0" src="headlight_protectors_files/Alfa_romeo_Logo.jpg"></td>
</tr>
<tr>
<td width="100%" height="24" align="center" colspan="8" bgcolor="#000000">
<font face="Arial Black" size="4" color="#FFFFFF">Headlight Protectors</font></td>
</tr>
<tr>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Part Number</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Make</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Model</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<p align="center"><font face="Arial Black" color="#FFFFFF">Year Range</font></td>
<td width="23%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Description</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Price</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Shipping Cost</font></td>
<td width="5%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
</td>
</tr>
<tr>
<?php
$db = mysql_connect("HOST_NAME","DB_NAME","DB_PASSWORD");
mysql_select_db("DB_NAME",$db);
$result = mysql_query("SELECT * FROM Items WHERE Category=35",$db);
while ($myrow = mysql_fetch_row($result)) (
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[7], $mysql[8]));
echo "</table>\n";
?>
</tr>
</table>
</div>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/view_cart_02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
</form>
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<p> </p>
</BODY></HTML>
and here is the script for the paypal link:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="hidden" name="item_name" value="ITEM_NAME_FROM_DB">
<input type="hidden" name="item_number" value="ITEM_NUMBER_FROM_DB">
<input type="hidden" name="amount" value="COST_FROM_DB">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
</form>
Please could someone help me with this as I have run out of ideas.
Thanks
Huw
Hey Huw,
You'll need to do something like this:
You'll need to do something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<HTML><HEAD>
<TITLE></title>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="website/Page1_files/page.css" rel=stylesheet>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META http-equiv=Last-Modified content=22/05/2004:08:35:13>
<META http-equiv=Pragma content=no-cache></HEAD>
<BODY>
<div align="center">
<center>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse; font-family:Arial Black; color:#FFFFFF; text-align:center" bordercolor="#000000" width="80%" id="AutoNumber1" bgcolor="#003163">
<tr>
<td width="100%" colspan="8" align="center" valign="top" height="1" bgcolor="#FFFFFF">
<img border="0" src="headlight_protectors_files/Alfa_romeo_Logo.jpg"></td>
</tr>
<tr>
<td width="100%" height="24" align="center" colspan="8" bgcolor="#000000">
<font face="Arial Black" size="4" color="#FFFFFF">Headlight Protectors</font></td>
</tr>
<tr>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Part Number</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Make</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Model</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<p align="center"><font face="Arial Black" color="#FFFFFF">Year Range</font></td>
<td width="23%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Description</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Price</font></td>
<td width="12%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
<font face="Arial Black" color="#FFFFFF">Shipping Cost</font></td>
<td width="5%" height="30" background="headlight_protectors_files/top_bg.jpg" align="center">
</td>
</tr>
<?php
$db = mysql_connect("HOST_NAME","DB_NAME","DB_PASSWORD");
mysql_select_db("DB_NAME",$db);
$result = mysql_query("SELECT * FROM Items WHERE Category=35",$db);
while ($myrow = mysql_fetch_row($result))
{
$paypal_code = '<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="hidden" name="item_name" value="'.$myrow[0].'">
<input type="hidden" name="item_number" value="'.$myrow[1].'">
<input type="hidden" name="amount" value="'.$myrow[2].'">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
</form>';
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[7], $paypal_code));
}
?>
</table>
</div>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="PAYPAL_ACCOUNT_USERNAME">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/view_cart_02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
</form>
<!-- This site was created by Huw Hughes - huw_hughes712@hotmail.com -->
<p> </p>
</BODY></HTML>
It's also good practice to clean-up when you're finished with your MySQL results:
This would go at the end of your while loop
php Syntax (Toggle Plain Text)
@mysql_free_result($result);
This would go at the end of your while loop
![]() |
Similar Threads
- Shopping basket contents to paypal (PHP)
- News Story: The eBay Effect: Holiday Shopping Season Booming Online? (eCommerce)
- Website shopping basket security (IT Professionals' Lounge)
- 1 in 3 paypal cart "sales" are canceled by buyer (eCommerce)
Other Threads in the PHP Forum
- Previous Thread: file upload code.....need attention
- Next Thread: Help : Adding GD Library in PHP
| Thread Tools | Search this Thread |
action address ajax apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display domain dynamic echo email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image include insert integration ip java javascript joomla legislation limit link load login loop mail masterthesis menu mlm multiple mysql oop open paypal pdf php popup problem query radio random record recursion regex remote script search security server sessions sms soap source space sql syntax system table tutorial update upload url validator variable video web xml youtube







