tgavin Posted March 13, 2007 Share Posted March 13, 2007 This problem I'm having is a result of having to update a table and query. If needed, check the original topic: http://www.phpfreaks.com/forums/index.php/topic,107845.0.html for background. I'm displaying a series of checkboxes, and ticking the ones the subscriber belongs to. This was working just fine, until I updated the table with a new column: subscribed. Here's the current query: $query = "SELECT n.ln_id, n.ln_name, s.ls_list_id FROM {$database}.list_names n LEFT JOIN {$database}.list_subscribers s ON n.ln_id = s.ls_list_id AND s.ls_sub_id = '".$id."'"; So, I need for this query to now 1. Show all checkboxes 2. tick off the ones in which subscribed=1 If I just put WHERE subscribed=1 into the query, then it only shows those checkboxes on the page, not all of them. Here's the table CREATE TABLE `list_subscribers` ( `ls_list_id` int(10) unsigned NOT NULL default '0', `ls_sub_id` int(10) unsigned NOT NULL default '0', `email` varchar(60) NOT NULL default '', `news_id` int(10) unsigned NOT NULL default '0', `subscribed` char(1) NOT NULL default '0', PRIMARY KEY (`ls_list_id`,`ls_sub_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/ Share on other sites More sharing options...
tauchai83 Posted March 13, 2007 Share Posted March 13, 2007 quote: then it only shows those checkboxes on the page, not all of them. did you mean it shows some checkboxe was ticked but some not???? Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/#findComment-206654 Share on other sites More sharing options...
tgavin Posted March 13, 2007 Author Share Posted March 13, 2007 no, it only showed the checkboxes in which the email address was subscribed to. I *want* it to show *all* checkboxes, and only tick off the ones the email address is subscribed to. Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/#findComment-206659 Share on other sites More sharing options...
per1os Posted March 13, 2007 Share Posted March 13, 2007 Why not run 2 separate queries? One to get the check boxes ticked and one to get where the check boxes aren't ticked? IE: use WHERE subscribed =1 and start that into $query1 and WHERE subscribed = 0 and store that into $query2. If for some reason that is not a viable option, well post some code. --FrosT Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/#findComment-206670 Share on other sites More sharing options...
tgavin Posted March 13, 2007 Author Share Posted March 13, 2007 That's not viable. It's a little complicated on how it's done. see this for the code: http://www.phpfreaks.com/forums/index.php/topic,107845.0.html Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/#findComment-206674 Share on other sites More sharing options...
tgavin Posted March 16, 2007 Author Share Posted March 16, 2007 I went a different route. Link to comment https://forums.phpfreaks.com/topic/42549-solved-query-help/#findComment-208534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.