943,851 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 6136
  • PHP RSS
Aug 2nd, 2004
0

Paypal shopping basket link

Expand Post »
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">
&nbsp;</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>&nbsp;</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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
huwgomez is offline Offline
6 posts
since Aug 2004
Aug 31st, 2007
0

Re: Paypal shopping basket link

Hey Huw,

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">
&nbsp;</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>&nbsp;</p>
</BODY></HTML>
jt1
Reputation Points: 13
Solved Threads: 3
Newbie Poster
jt1 is offline Offline
19 posts
since Aug 2007
Aug 31st, 2007
0

Re: Paypal shopping basket link

It's also good practice to clean-up when you're finished with your MySQL results:

php Syntax (Toggle Plain Text)
  1. @mysql_free_result($result);

This would go at the end of your while loop
jt1
Reputation Points: 13
Solved Threads: 3
Newbie Poster
jt1 is offline Offline
19 posts
since Aug 2007
Aug 31st, 2007
0

Re: Paypal shopping basket link

I'm sure Huw would have found this information very helpful - three years ago

Still, perhaps someone else will have a similar need and find it here now.
Last edited by Ezzaral; Aug 31st, 2007 at 2:12 pm.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Aug 31st, 2007
0

Re: Paypal shopping basket link

Hehe, sorry, my bad. I suppose that's what you get for answering at 3am on a Sunday morning.

You'll probably see a couple of others where I didn't read the date...

I'll apologise now in advance
jt1
Reputation Points: 13
Solved Threads: 3
Newbie Poster
jt1 is offline Offline
19 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: file upload code.....need attention
Next Thread in PHP Forum Timeline: Help : Adding GD Library in PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC