Hello,
Im a noob when it comes to php, and Im trying to figure out how to work out a code that will allow me to filter out an array.
Basically, I have a system to assign offers to my clients and I have a page that is used to assign offers. Once all offers are assigned to a client, I dont want the form to be displayed anymore, but i cant get it work. here is the code:
[PHP]$html .= "<div style='backgrou nd-image:url(image s/gradientdiv.gif ); height:26px;'>$ row[firstname] $row[lastname](<a href=\"javascri pt:showDiv('div $member_id');\" style='color:bl ue;'>Assign Offers</a>)</div> <div id='div$member_ id' style='display: none; background-color:#FFFFD9;' >"; $sql_select_off ers = "select o.offer_id, o.offer_name from offers o where not exists (select * from members_offers inner join offers on members_offers. offer_id = offers.offer_id where members_offers. member_id = $member_id and o.offer_id = offers.offer_id )"; $result_set_off ers = mysql_query($sq l_select_offers ); $html .= '<form action="assign_ offers.php">Che ck to Assign:<br />'; $html .= "<input type='hidden' name='member_id ' value='$member_ id' />"; while($row = mysql_fetch_arr ay($result_set_ offers)) { $html .= "<input type='checkbox' name='$row[offer_id]' value='$row[offer_id]' />$row[offer_name]<br />"; } $html .= "<input type='submit' value='Save' /></form></div>"; }[/PHP]
The code works fine, but it retrieves all users from the DB, and even those that have all offers already assigned to them, so basically I end up having a <div> tag with only "check to assign" and the save button in it. How can I hide those records that have offers all assigned already?
Thanks a bunch!!!
Im a noob when it comes to php, and Im trying to figure out how to work out a code that will allow me to filter out an array.
Basically, I have a system to assign offers to my clients and I have a page that is used to assign offers. Once all offers are assigned to a client, I dont want the form to be displayed anymore, but i cant get it work. here is the code:
[PHP]$html .= "<div style='backgrou nd-image:url(image s/gradientdiv.gif ); height:26px;'>$ row[firstname] $row[lastname](<a href=\"javascri pt:showDiv('div $member_id');\" style='color:bl ue;'>Assign Offers</a>)</div> <div id='div$member_ id' style='display: none; background-color:#FFFFD9;' >"; $sql_select_off ers = "select o.offer_id, o.offer_name from offers o where not exists (select * from members_offers inner join offers on members_offers. offer_id = offers.offer_id where members_offers. member_id = $member_id and o.offer_id = offers.offer_id )"; $result_set_off ers = mysql_query($sq l_select_offers ); $html .= '<form action="assign_ offers.php">Che ck to Assign:<br />'; $html .= "<input type='hidden' name='member_id ' value='$member_ id' />"; while($row = mysql_fetch_arr ay($result_set_ offers)) { $html .= "<input type='checkbox' name='$row[offer_id]' value='$row[offer_id]' />$row[offer_name]<br />"; } $html .= "<input type='submit' value='Save' /></form></div>"; }[/PHP]
The code works fine, but it retrieves all users from the DB, and even those that have all offers already assigned to them, so basically I end up having a <div> tag with only "check to assign" and the save button in it. How can I hide those records that have offers all assigned already?
Thanks a bunch!!!
Comment