Create a Function from a button
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Okay, seeing what your stuff it outputing, those functions are definitely echoing. Here's what to do, replace this:
with:or:there are a few more ways to do it, but that gets it done.
Code: Select all
<?php
function renderpaypal() {
echo "<form action="https://www.paypal.com/cgi-bin/webscr" method="post">\n";
echo "<input type="hidden" name="cmd" value="_xclick" />\n";
echo "<input type="hidden" name="business" value="" . renderSingleListingItemRaw($listingID, "email") . "" />\n";
echo "<input type="hidden" name="item_name" value="" . renderSingleListingItemRaw($listingID, "item_name") . "" />\n";
echo "<input type="hidden" name="amount" value="" . renderSingleListingItemRaw($listingID, "amount") . "" />\n";
echo "<input type="hidden" name="return" value="http://www.mysite.com" />\n";
echo "<input type="hidden" name="notify_url" value="http://www.mysite.com" />\n";
echo "<input type="image" src="https://www.paypal.com/images/x-click-but23.gif" name="submit" />\n";
echo "</form>\n";
}
renderpaypal(); // Now we are calling it ..
?>Code: Select all
<?php
function renderpaypal() {
$listingID = $GLOBALS['listingID'];
echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">\n';
echo '<input type="hidden" name="cmd" value="_xclick" />\n';
echo '<input type="hidden" name="business" value="';
renderSingleListingItemRaw($listingID, "email");
echo '" />\n';
echo '<input type="hidden" name="item_name" value="';
renderSingleListingItemRaw($listingID, "item_name");
echo '" />\n';
echo '<input type="hidden" name="amount" value="';
renderSingleListingItemRaw($listingID, "amount");
echo '" />\n';
echo '<input type="hidden" name="return" value="http://www.mysite.com" />\n';
echo '<input type="hidden" name="notify_url" value="http://www.mysite.com" />\n';
echo '<input type="image" src="https://www.paypal.com/images/x-click-but23.gif" name="submit" />\n';
echo '</form>\n';
}
renderpaypal(); // Now we are calling it ..
?>Code: Select all
<?php
function renderpaypal() {
$listingID = $GLOBALS['listingID'];
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">\n;
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="<? renderSingleListingItemRaw($listingID, "email"); ?>" />
<input type="hidden" name="item_name" value="<? renderSingleListingItemRaw($listingID, "item_name"); ?>" />
<input type="hidden" name="amount" value="<? renderSingleListingItemRaw($listingID, "amount"); ?>" />
<input type="hidden" name="return" value="http://www.mysite.com" />
<input type="hidden" name="notify_url" value="http://www.mysite.com" />
<input type="image" src="https://www.paypal.com/images/x-click-but23.gif" name="submit" />
</form>
<?
}
renderpaypal(); // Now we are calling it ..
?>Whoa! Thats perfect! Just what I needed. Thank you sooo much for the help man I've been messin with this ALL Day! I really appreciate it!
Thanks.
NYColt
Next thing I need to do is create an "if" statement for the item_name field. if the item_name is empty I don't want the button to show. if the item_name field is Full then I want the button to appear. That is what I need to do right? I mean an if statement is what I need right? is there something better or something easier that you know of?
Hey THANKS AGAIN! Goin to BED
Have a Good one!
Thanks.
NYColt
Next thing I need to do is create an "if" statement for the item_name field. if the item_name is empty I don't want the button to show. if the item_name field is Full then I want the button to appear. That is what I need to do right? I mean an if statement is what I need right? is there something better or something easier that you know of?
Hey THANKS AGAIN! Goin to BED
Have a Good one!
I was wondering if you could take a look at this and give me an idea as to how far off I am.
<?php
if (renderSingleListingItemRaw ($listingID, "paypalseller" = "yes")
{
renderpaypal();
}
?>
In case I am sooo far off that you can't tell what I want to do here, I am trying to call the function renderpaypal(); with an if statement
if paypalseller = yes
Any help would be GREAT!
Thanks
NYColt
<?php
if (renderSingleListingItemRaw ($listingID, "paypalseller" = "yes")
{
renderpaypal();
}
?>
In case I am sooo far off that you can't tell what I want to do here, I am trying to call the function renderpaypal(); with an if statement
if paypalseller = yes
Any help would be GREAT!
Thanks
NYColt
Would I do that within the function itself? Would I add something like this to the function or can I do it seperate from the function?
$listingID = make_db_extra_safe($listingID);
$sql = "SELECT ID, field_name FROM " . "default_listingsDBElements WHERE (paypaluser);
if ($listingID, "paypalseller" = "yes")
{
renderpaypal();
}
$listingID = make_db_extra_safe($listingID);
$sql = "SELECT ID, field_name FROM " . "default_listingsDBElements WHERE (paypaluser);
if ($listingID, "paypalseller" = "yes")
{
renderpaypal();
}
feyd wrote:you'll have to do a query somewhere along the line to get that variable, so yeah.