So that I can dynamically determine which paypal seller e-mail address to use when clicking the Buy Now button, I would like to retrieve the paypal e-mail address using an sql query based on a selection from a Select Option (dropdown) box.
Does anybody know if this can be done? This is the code I have so far, but it doesn't capture the value.
public function getForm($project_list, $business){
?>
<div id="payment_booking_main">
<!-- <form name="_xclick" id="payment_booking_form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> -->
<form name="_xclick" id="payment_booking_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="hosted_button_id" value="7ACEDNW8URDK2" />
<!-- <input type="hidden" name="business" value="myemailaddress@website.info" /> -->
<!-- try to populate business field for paypal e-mail address -->
<input type="hidden" name="business" value="
<?php
global $wpdb;
$paymentProject = $_POST['payment_booking_project'];
$result = $wpdb->get_results("SELECT project_paypal_address FROM {$wpdb->prefix}payment_booking_project WHERE project_name='{$paymentProject}'");
echo $result->project_paypal_address;
?>" />
<input type="hidden" name="a3" value="1">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="D">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" id="payment_booking_return_url" name="return" value="" />
<input type="hidden" id="payment_booking_notify_url" name="notify_url" value="">
<input type="hidden" id="payment_booking_total_amount" name="amount" value="0">
<input type="hidden" id="payment_booking_item_name" name="item_name" value="">
<input type="hidden" id="payment_booking_item_number" name="item_number" value="">
Edit:
To provide a little more context, when this form loads, it populates a <select>
input from the database. I want to use part of the results of this to find the e-mail address. This PHP looks as below:
<div id="payment_booking_project_selectform">
<div class="payment_booking_line" style="heigth:20px !important;">
<span class="payment_booking_label">Project :</span>
<select id="payment_booking_project" name="payment_booking_project">
<?php
global $wpdb;
$sql = "SELECT * FROM `{$wpdb->prefix}payment_booking_project` WHERE project_status =1";
$project_list = $wpdb->get_results($sql);
foreach($project_list as $project){
echo '<option value="'.$project->id.'" amount="'.number_format($project->project_amount, 2).'" description="'.$project->project_description.'" price="'.$project->project_price.'">'.$project->project_name.'</option>';
}
?>
</select>
<span id="payment_booking_project_description" style="font-size:12px;"></span>
</div>