I need to take a drop box and have it display the co_id from another table
I have a table coupons which lists all coupons available
coupons table
id,name,desc
Coupon_users table
id,co_id,mem_id,email
now in the drop box i know i have to select from the coupon_users table and user where something = something which would be from coupons table but not sure what
here is some code i have
Code: Select all
$r = mysql_query("select * from coupon_users") or die(mysql_error());
$cop = mysql_fetch_array($r, MYSQL_ASSOC);
@mysql_free_result($r);
Code: Select all
<select name="coupons_a">
<?php
$r = mysql_query("SELECT * from coupons WHERE id ='".$cop['co_id']."' ") or die(mysql_error());
while($co = mysql_fetch_array($r, MYSQL_ASSOC)) {
echo '<option value="'.$co['id'].'">'.$cop['co_id'].'</option>';
}
?>
</select>
I hope someone can help I know I am close
also should be able to show if the users has more then one coupon which would be the co_id so if they have 3 then in drop box it should show 3 numbers each number being a coupon id
Thanks