Jump to content

I need some help with showing a Paypal buy button or not if it's sold.


vet911

Recommended Posts

I need some help with showing a Paypal buy button or not if it's sold. Currently if the item is sold I mark it as sold but the button is still there. What I need I believe is an if statement to look at the sold variable to see if it's sold and then not show the Paypal Buy it button for that item only.

Any help would be greatly appreciated. Below is some of the code I use.

 

$result = mysql_query("SELECT * FROM $dbname ORDER BY itemno ASC") or die(mysql_error());
// store the record of the "" table into $row
$current = '';

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
$id = $row['id'];
if (!$current) {
echo "<center><div><table border='0' width='520'>";
$current = $id;
echo "<div id='box'>";
	echo "<h4>Welcome to the Store</h4>";
	echo "<p>Questions about store items use link in menu.</p>";
	echo "Beads (".$rows4.") ";
	echo "Cabochons (".$rows3.") ";
echo "Earrings (".$rows1.") ";
echo "Pendants (".$rows2.") ";
echo "Rings (".$rows0.") ";
    echo "</div>";
    echo "<p>Click picture to enlarge.</p>";
echo "<hr width='520'>";
} elseif ($current != $id){
echo "</table></div><br><div><table border='0' width='520'>";
$current = $id;
echo "<hr width='520'>";
}
?>
<tr><td rowspan="6" width="100"><div class="image"><a href="<?= $row['image']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image_th']; ?>" align="center" border="0"></a></div></td>
<td rowspan="6" width="100"><div class="image"><a href="<?= $row['image2']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image2_th']; ?>" width="75" border="0"></a></div></td>
<th width='100' align="left">Item No.</th><td><?= $row['itemno']; ?></div> </td></tr>
<tr><th align="left">Description</th><td><?= $row['description']; ?></td></tr>
<tr><th align="left">Carat</th><td><?= $row['carat']; ?></td></tr>
<tr><th align="left">Material</th><td><?= $row['material']; ?></td></tr>
<tr><th align="left">Price</th><td><?= $row['price']; ?></td></tr>
<tr><th align="left">Availability</th><td><?= $row['availability']; ?></td></tr>
<tr><th> </th><td> </td><td><form target="paypal" action="https://www.paypal.com" method="post">
                        <input type="hidden" name="cmd" value="_cart">
				    <input type="hidden" name="add" value="1">
				    <input type="hidden" name="business" value="">
				    <input type="hidden" name="item_name" value="<?= $row['description']; ?>">
				    <input type="hidden" name="item_number" value="<?= $row['itemno']; ?>">
				    <input type="hidden" name="amount" value="<?= $row['price']; ?>">
				    <input type="hidden" name="shipping" value="7.00">
				    <input type="hidden" name="shipping2" value="0.50">
				    <input type="hidden" name="handling" value="2.00 ">
				    <input type="hidden" name="currency_code" value="USD">
				    <input type="hidden" name="return" value="thankyou.html">
				    <input type="hidden" name="undefined_quantity" value="1">
				    <input type="image" src="" height="65%" border="0" name="submit"  alt="Make payments with PayPal - it's fast, free and secure!">


	</form>
	</td>
</tr>

Link to comment
Share on other sites

Okay, I though I had it until I got this error message:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/r/i/g/rigtway/html/toveco/store/records_test.php on line 64

 

This is line 64: echo "<input type='hidden' name='item_name' value='<?php $row['description'];?>'>";

 

Any help would be appreciated!

Thank you

 

while($row = mysql_fetch_array( $result )) {
    $id = $row['id'];
if (!$current) {
    echo "<center><div><table border='0' width='520'>";
    $current = $id;
    echo "<div id='box'>";
     echo "<h4>Welcome to the Store</h4>";
     echo "<p>Questions about store items use link in menu.</p>";
     echo "Beads (".$rows4.") ";
     echo "Cabochons (".$rows3.") ";
    echo "Earrings (".$rows1.") ";
    echo "Pendants (".$rows2.") ";
    echo "Rings (".$rows0.") ";
    echo "</div>";
    echo "<p>Click picture to enlarge.</p>";
    echo "<hr width='520'>";
} elseif ($current != $id){
    echo "</table></div><br><div><table border='0' width='520'>";
    $current = $id;
    echo "<hr width='520'>";
}
?>
<tr><td rowspan="6" width="100"><div class="image"><a href="<?= $row['image']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image_th']; ?>" align="center" border="0"></a></div></td>
<td rowspan="6" width="100"><div class="image"><a href="<?= $row['image2']; ?>" rel="lightbox" title="<?= $row['material']; ?>"><img src="<?= $row['image2_th']; ?>" width="75" border="0"></a></div></td>
<th width='100' align="left">Item No.</th><td><?= $row['itemno']; ?></div> </td></tr>
<tr><th align="left">Description</th><td><?= $row['description']; ?></td></tr>
<tr><th align="left">Carat</th><td><?= $row['carat']; ?></td></tr>
<tr><th align="left">Material</th><td><?= $row['material']; ?></td></tr>
<tr><th align="left">Price</th><td><?= $row['price']; ?></td></tr>
<tr><th align="left">Availability</th><td><?= $row['availability']; ?></td></tr>
<tr><th> </th><td> </td><td>
<?php if (!$sold){
    echo "<form target='paypal' action='https://xxx.com/cgi-bin/webscr' method='post'>";
    echo "<input type='hidden' name='cmd' value='_cart'>";
    echo "<input type='hidden' name='add' value='1'>";
    echo "<input type='hidden' name='business' value=' '>";
    echo "<input type='hidden' name='item_name' value='<?php $row['description'];?>'>";
    echo "<input type='hidden' name='item_number' value='<?php $row['itemno']; ?>'>";
    echo "<input type='hidden' name='amount' value='<?php $row['price']; ?>'>":
    echo "<input type='hidden' name='shipping' value='7.00'>";
    echo "<input type='hidden' name='shipping2' value='0.50'>";
    echo "<input type='hidden' name='handling' value='2.00 '>";
    echo "<input type='hidden' name='currency_code' value='USD'>";
    echo "<input type='hidden' name='return' value='http://store/paypal/thankyou.html'>":
    echo "<input type='hidden' name='undefined_quantity' value='1'>";
    echo "<input type='image' src='http://images.paypal.com/en_US/i/btn/btn_cart_SM.gif' height='65%' border='0' name='submit'  alt='Make payments with PayPal - it's fast, free and secure!'>";
    echo "</form>";

    }$if ($sold) {<img src="/images/sold.gif">}?>
        </td>
</tr>

Link to comment
Share on other sites

indeed!

<?php // opening tag

echo "<input type='hidden' name='item_name' value='<?php $row['description'];?>'>"; // don't use php tags within others
    echo "<input type='hidden' name='item_number' value='<?php $row['itemno']; ?>'>"; //idem
    echo "<input type='hidden' name='amount' value='<?php $row['price']; ?>'>"://idem

?> <!-- closing tag-->

 

either don't use echo and use <?php your stuff ?> in the fields

or dont use the <?php ?> to fill fields if you are already using echo and thus being within tags.

 

-edit- Oh btw, carefull with hiddenfields and critical data, like prices. I am not sure what process is going on, but do realize someone could alter the hidden fields and to say 1 cent : ) Better store prices in a database and store it in a session and after payment compare the payment with the value/price in the database. Some Pizza website in my country didn't. : ) Too bad I am not evil and dislike fluffy pizza's

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.