php - showing promotion codes on pages
I have a few php pages designed to search the database for promotion codes I created in the admin panel
I am struggling to echo these codes out to the promotional pages
my advert is simple
advert.php
<body>
<div>
<!-- Start SPECIAL OFFER/PROMO -->
<div id="specialPromo" >
<p >promotion title!</p>
<p >here is our promotion code</p>
<div >
<!-- PROMO CODE -->
<p ><?echo $showcode?></p>
<!-- PROMO CODE -->
</div>
<div ><a href="index.php?action=signup">JOIN NOW</div></a></div>
<!-- End SPECIAL OFFER/PROMO -->
</div>
</body>
</html>
this then links to another page
getcode.php
<?
include ("include/universal.php");
//execute the SQL query and return records
$result = mysql_query("SELECT discount_code FROM discount_codes WHERE discount_name='".$code."'");
//fetch tha data from the database
while ($row = mysql_fetch_array($result))
{
$showcode = ($row{'discount_code'});
}
//close the connection
mysql_close($condb);
?>
the problem lies with this bit of code
$code = $code["code1"];
works fine and gets results if I place it in the getcodes.php
but I want to place it in the advert.php
ultimately the plan would be to create a single admin page where I can select an advert and input the codename and it will auto-populate the code to be used with in that advert
but I cant even get it to work with a single advert, unti I figure that out I have no chance of administrating multiple adds from a single page
any advice please as to where I am going wrong, bear in mind I have only been using php for 2 weeks now
thank you all for your advice in advance
Answer
Solution:
after a lot of reading I figured it out, it was simple so not sure why no one managed to help, maybe it elitism, I have found that among other websites
any way here is how I solved it
I changed my getcodes.php to:
the important bit was
and
which allowed me to then use
by simply using the following where I want to out put the results
obviously ? whoud be changed to a number representative of the current discount code being offered
using this option allowed me to remove the need to post anything from the advert page into the search to pull the desired code, this just pull them all and then allows me to select which one to echo out