Php lightbox with paypal

Hi guys im having trouble trying to work out how to add a paypal button to this using php. I have done it with straight html but its proving to be very time consuming with over 100 photos!

what i want to know is how could i insert this html into this php script

$link = "<a rel=\\"lightbox[" . $images . "]\\" title=\\"$splitname[0]\\" href=\\"" . $images . "/" . $name . "\\">";

this html would need to be after the splitname[0]\

paypalform="<!--Start Code-->
<form target=&quot;paypal&quot; action=&quot;; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;cmd&quot; value=&quot;_s-xclick&quot;>
<input type=&quot;hidden&quot; name=&quot;hosted_button_id&quot; value=&quot;PYRPPX9ZMBMCL&quot;>
<tr><td><input type=&quot;hidden&quot; name=&quot;on0&quot; value=&quot;image name&quot;>image name</td></tr><tr><td><select name=&quot;os0&quot;>
<option value=&quot;Option 1&quot;>Option 1 £5.00</option>
<option value=&quot;Option 2&quot;>Option 2 £10.00</option>
<option value=&quot;Option 3&quot;>Option 3 £15.00</option>
</select> </td></tr>
<input type=&quot;hidden&quot; name=&quot;currency_code&quot; value=&quot;GBP&quot;>
<input type=&quot;image&quot; src=&quot;; border=&quot;0&quot; name=&quot;submit&quot; alt=&quot;PayPal - The safer, easier way to pay online.&quot;>
<img alt=&quot;&quot; border=&quot;0&quot; src=&quot;; width=&quot;1&quot; height=&quot;1&quot;>

any ideas??? please hlep

any ideas???

Pro tip: even with just a single question mark, people will still know you’re asking a question.

Anyway, you don’t want that PayPal form immediately after splitname[0] because that would still be within the <a> element. You can have attributes in the element, but not another element.

Even between <a> and </a> it wouldn’t make sense because you can’t have a form inside a link.

You can assign your form code to a variable like this:

$paypalform = <<<EOD
<!--Start Code-->
<form target="paypal" action="" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="PYRPPX9ZMBMCL">
<tr><td><input type="hidden" name="on0" value="image name">image name</td></tr><tr><td><select name="os0">
<option value="Option 1">Option 1 &pound;5.00</option>
<option value="Option 2">Option 2 &pound;10.00</option>
<option value="Option 3">Option 3 &pound;15.00</option>
</select> </td></tr>
<input type="hidden" name="currency_code" value="GBP">
<input type="image" src="" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="" width="1" height="1">

You can drop other variables into it to vary each product.

thanks for your help i understand what you mean but im using lightbox to display the image and the above code with the paypal funcion in the <a> is how it works with standard html. How would you recomend using this then?

Well you should be able to replicate your static HTML like this.
Note that HTML attributes can be quoted with a single or double quote. So if you use the opposite to the PHP string you don’t need to do so much escaping, and your code will be easier to read

$link = "<a rel='lightbox[$images]' title='$splitname[0] $paypalform' href='$images/$name'>";