jmr3460 Posted October 19, 2009 Share Posted October 19, 2009 I have been working on a project for some time a couple of hours a day or so. I have developed an admin site that inserts information about groups that meet at regular times every week. My inserts are working great. There are no duplicate entries unless I unintentionally add 1 more that once. My problem is when the group meets more that once a day, my query results duplicate the results for that day the number of times that the group meets. My server is using PHP 5.2.9 and MYSQL 5.0.81. My Code is elementary I know I am learning as I go. I have I think 4 while loops nested and the only one giving me a problem it seems is the day loop. Here it is: <?php /*of course there is code above this that gets me in my Database*/ $sql_group_info = "SELECT * FROM group_info ORDER BY groupname"; $group_query = mysql_query($sql_group_info) or die(mysql_error()); while ($group_data = mysql_fetch_array($group_query)){ $groupname= $group_data['groupname']; $area_id = $group_data['area_id']; $group_id = $group_data['id']; $sql_area = "SELECT * FROM area WHERE id = '$area_id'"; $area_query = mysql_query($sql_area) or die(mysql_error()); $area_data = mysql_fetch_array($area_query); $area = $area_data['acronym']; $phoneline = $area_data['phoneline']; echo "<b><table><tr><td style=\"width:250px;color:red;vertical-align:top;\"><b>" .$groupname . "</td></b><td style=\"width:250px;text-align:right;\">Area Afiliation:<b>" . $area . "</b><br /></td></tr></table>"; //start 1st nested while loop $sql_location = "SELECT * FROM location WHERE group_id = $group_id"; $sql_result_location = mysql_query($sql_location) or die(mysql_error()); while ($result_location = mysql_fetch_array($sql_result_location)){ $location_id = $result_location['id']; $address = $result_location['address']; $city = $result_location['city']; $state = $result_location['state']; $zip = $result_location['zip']; $map = $result_location['map']; echo "<span style=\"color:blue;\">" .$address . "</span><br />" . $city . ", " . $state . " " . $zip . " " . $map . "<br />"; //start 2nd nested while loop $sql_meeting = "SELECT * FROM day_time WHERE location_id = '$location_id'"; $result_meeting = mysql_query($sql_meeting) or die(mysql_error()); while ($data_meeting = mysql_fetch_array($result_meeting)){ $day_id = $data_meeting['day_id']; $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); if ($day_id == 1){ $day = $days[0]; } elseif ($day_id == 2) { $day = $days[1]; } elseif ($day_id == 3) { $day = $days[2]; } elseif ($day_id == 4) { $day = $days[3]; } elseif ($day_id == 5) { $day = $days[4]; } elseif ($day_id == 6) { $day = $days[5]; } elseif ($day_id == 7) { $day = $days[6]; } echo "<b>$day</b><br />"; $sql_meeting2 = "SELECT * FROM day_time WHERE location_id = '$location_id' AND day_id = '$day_id' ORDER BY hour"; $result_meeting2 = mysql_query($sql_meeting2) or die(mysql_error()); while($data_meeting2 = mysql_fetch_array($result_meeting2)){ $hours = $data_meeting2['hour']; $minute = $data_meeting2['minute']; $open = $data_meeting2['open']; $format = $data_meeting2['format']; if ($hours >= 12){ $am = "PM"; } else { $am = "AM"; } if ($hours > 12) { $hour = ($hours - 12); } elseif ($hours < 13) { $hour = $hours; } if ($minute == 0){ $minutes = "00"; } else { echo $minute; } if ($open == 1){ $opens = "Open"; } else { $opens = "Closed"; } $time = $hour . ":" . $minutes . $am; echo "<table width=\"650px\"> <tr><td width=\"250px\">$time</td><td>$opens:$format</td></tr>"; echo "</table>"; }//end 4th while }//end 3rd while }//end 2nd while }//end 1st while ?> This produces a repeating effect on the days that have more that one meeting time in one day. Here is how the page is produced. Sunday 1:00PM Closed:Discussion, 7:00PM Closed:Discussion, Sunday 1:00PM Closed:Discussion, 7:00PM Closed:Discussion, Monday 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Wednesday 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Friday 7:00AM Closed:Discussion, 12:00PM Closed:Discussion, Saturday 10:00AM Closed:Discussion, Women, 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Monday 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Tuesday 12:00PM Closed:Discussion, 7:00PM Open:Discussion, Wednesday 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Thursday 12:00PM Closed:Discussion, 7:00PM Open:Discussion, Friday 7:00AM Closed:Discussion, 12:00PM Closed:Discussion, Saturday 10:00AM Closed:Discussion, Women, 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, Tuesday 12:00PM Closed:Discussion, 7:00PM Open:Discussion, Thursday 12:00PM Closed:Discussion, 7:00PM Open:Discussion, Saturday 10:00AM Closed:Discussion, Women, 12:00PM Closed:Discussion, 7:00PM Closed:Discussion, I hope you can help I am so close to being finished with this project. I do feel this is a query issue, but it could be a while loop issue. All that is left is a couple of update pages and a couple of other query by category pages. Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/ Share on other sites More sharing options...
anatak Posted October 19, 2009 Share Posted October 19, 2009 I am not sure if I understand your problem if a group meets more than once a day the query selects the results the number or meetings ? for example group women meets 2 times on wednesday what it the result of your query ? can you give us the structure of your database ? BTW read this if you have time (kinda important) http://www.phpfreaks.com/blog/or-die-must-die Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-939455 Share on other sites More sharing options...
jmr3460 Posted October 19, 2009 Author Share Posted October 19, 2009 Yea I have 5 tables: area with 4 fields id INT(3) primary key auto_increment acronym VARCHAR(15) name VARCHAR(50) phoneline VARCHAR(15) next is day with 2 fields id INT(3) primary key auto_increment day VARCHAR(10) next is day_time with 8 fields id INT(3) primary key auto_increment group_id INT(3) location_id INT(3) day_id INT(3) hour INT(3) minute INT(3) open TiNYINT(1) format VARCHAR(255) next is group_info with 6 fields id INT(3) primary key auto_increment groupname VARCHAR(30) area_id INT(3) naws_number VARCHAR(15) banner TINYINT(1) email VARCHAR(100) next is location with 10 fields id INT(3) primary key auto_increment group_id INT(3) address VARCHAR(100) city VARCHAR(25) stateVARCHAR(2) zip VARCHAR(11) location VARCHAR(100) accessible TINYINT(1) map VARCHAR(150) notes VARCHAR(255) Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-939459 Share on other sites More sharing options...
fenway Posted October 19, 2009 Share Posted October 19, 2009 Why so many queries? Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-939629 Share on other sites More sharing options...
jmr3460 Posted October 20, 2009 Author Share Posted October 20, 2009 I guess there are so many queries because it is the only way that I know at this time. I am trying to create a list of meetings for over 75 groups. Each group meets in different cities on different days and different times. I see this in my head to call the city first then the days the group meets and for each day some groups meet more that one time a day and some have different topics for different times. I have read a lot on JOINs but I just can not see how to pull the information from the tables so they are called in the order I am looking for. I really want to do this the most efficient way which is probably the easiest way I just don't see it in my head yet. If there is one query that will do this with all five tables please help me understand it! Everything I have learned is self taught from this forum php.net and books. Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-940152 Share on other sites More sharing options...
jmr3460 Posted October 20, 2009 Author Share Posted October 20, 2009 OK after Fenways question I am going to attempt one query with subqueries in it. I need the city first so I will start there. Before I get too much more involved in this query I would like to ask a question. Do my tables seem to be normalized? I tried to make sure there was a few a duplicates as I could tell. Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-940788 Share on other sites More sharing options...
xtopolis Posted October 21, 2009 Share Posted October 21, 2009 Do my tables seem normalized?Nothing stood out as bad after a quick glance... the only thing maybe worth considering is in your day_time table -- if hour/minute need their own columns, or if it could be single column of DATETIME type (this of course depends on your intention for the data stored there). Additionally, it's debatable, but you could separate the "location" table zip, state, city files as per this mysql article (though its not immediately necessary). At this point it may be best to post some MySQL dumps of your structures (the kind we can easily copy/paste) as well as some sample data and the desired output (mysql, not php). I can see where this could be possibly one query, but it depends on what data you need. I realize you have posted some pseudo-output above, but that isn't really easily understandable. Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-940828 Share on other sites More sharing options...
jmr3460 Posted October 21, 2009 Author Share Posted October 21, 2009 Thanks for the reply. Yea this is probably one of my issues. I am fairly new to mysql or any other databases and I am using phpmyadmin to create my tables. I really do not know how to do a mysqldump. I am responsible for updating a meeting directory for a group of some friends. I have built this site with only html and it is very time consuming to edit the updates, you know staring through code and finding my place so I had this idea to create a database project where I can open an admin page and find the place that needs to be edited through forms from a database. So far I have most all my forms finished and now I am trying to create a search page if you will that will display a list of meetings for this group of friends. As I mentioned earlier there are about 75+ groups, each with their own time and formats. As far as desired output maybe I could give you a link of the html page http://www.arscna.org/meetings . I hope this is not against the rules for giving you this link but it is the best way for me to show you my desired output. Thanks for any help! I have read the article and I am still learning how to set up my tables. I am willing to do some rearranging of some of my tables if it will help me with this project, but it may take some time since I have several forms for inserts and updates to these tables that will have to be edited. Again thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-940873 Share on other sites More sharing options...
jmr3460 Posted October 22, 2009 Author Share Posted October 22, 2009 OK I finally learned how to do a dump. I am going to dump 5 tables with all the information I have so far. Then I will show the query I have at this moment. Table structure for table `group_inof` CREATE TABLE IF NOT EXISTS `group_info` ( `id` int(3) unsigned NOT NULL auto_increment, `groupname` varchar(35) NOT NULL, `area_id` int(3) NOT NULL, `naws_number` varchar(15) NOT NULL, `banner` tinyint(1) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `group_info` -- INSERT INTO `group_info` (`id`, `groupname`, `area_id`, `naws_number`, `banner`, `email`) VALUES (1, 'Cope Without Dope', 3, '', 1, 'abc@yahoo.com'), (2, 'Clean Slate', 3, '', 0, 'def@comcast.net'), (3, 'Clean A.I.R. of Paragould', 3, '', 0, 'ghi@yahoo.com'); Here is my 2nd table: -- -- Table structure for table `location` -- CREATE TABLE IF NOT EXISTS `location` ( `id` int(3) unsigned NOT NULL auto_increment, `group_id` int(3) NOT NULL, `address` varchar(50) NOT NULL, `city` varchar(25) NOT NULL, `state` varchar(15) NOT NULL, `zip` varchar(10) NOT NULL, `location` varchar(50) NOT NULL, `accessible` tinyint(1) NOT NULL, `map` varchar(200) NOT NULL, `notes` text NOT NULL, `del` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Dumping data for table `location` -- INSERT INTO `location` (`id`, `group_id`, `address`, `city`, `state`, `zip`, `location`, `accessible`, `map`, `notes`, `del`) VALUES (1, 3, '308 South 10th St.', 'Paragould', 'AR', '72450', 'All Saints Episcopal Church', 1, '<a href="http://www.google.com/maps/?hl=en&q=308 South 10th St.,Paragould,AR72450" target="_blank">MAP</a>', '', 0), (2, 3, '524 East Court Street', 'Paragould', 'AR', '72450', 'Griffin Memorial United Methodist Church', 1, '<a href="http://www.google.com/maps/?hl=en&q=524 East Court Street,Paragould,AR72450" target="_blank">MAP</a>', 'Use Back Entrance', 0), (3, 2, '209 Park Dr.', 'West Memphis', 'AR', '72301', 'Holy Cross Episcopal Church', 1, '<a href="http://www.google.com/maps/?hl=en&q=209 Park Dr.,West Memphis,AR72301" target="_blank">MAP</a>', 'Parrish Hall', 0), (4, 1, '5323 East Nettleton Ave.', 'Jonesboro', 'AR', '72401', 'Couch''s BBQ', 1, '<a href="http://www.google.com/maps/?hl=en&q=5323 East Nettleton Ave.,Jonesboro,AR72401" target="_blank">MAP</a>', '', 0), (5, 1, '900 West Huntington Ave.', 'Jonesboro', 'AR', '72401', 'Old Huntington United Methodist', 1, '<a href="http://www.google.com/maps/?hl=en&q=900 West Huntington Ave.,Jonesboro,AR72401" target="_blank">MAP</a>', '', 0); Here goes table 3: -- -- Table structure for table `day_time` -- CREATE TABLE IF NOT EXISTS `day_time` ( `id` int(3) unsigned NOT NULL auto_increment, `group_id` int(3) NOT NULL, `location_id` int(3) NOT NULL, `day_id` int(2) NOT NULL, `hour` int(2) NOT NULL, `minute` int(2) NOT NULL, `open` tinyint(1) NOT NULL, `format` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ; -- -- Dumping data for table `day_time` -- INSERT INTO `day_time` (`id`, `group_id`, `location_id`, `day_id`, `hour`, `minute`, `open`, `format`) VALUES (1, 3, 1, 2, 18, 0, 1, 'Basic Text Study, '), (2, 3, 1, 3, 18, 0, 1, 'Discussion, '), (3, 3, 1, 5, 18, 0, 1, 'Discussion, '), (4, 3, 1, 6, 18, 0, 1, 'Discussion, '), (5, 3, 1, 4, 12, 0, 1, 'Other'), (6, 3, 2, 7, 20, 0, 1, 'Other'), (7, 2, 3, 2, 20, 0, 1, 'Discussion, '), (8, 2, 3, 4, 20, 0, 1, 'Basic Text Study, '), (9, 1, 5, 1, 13, 0, 0, 'Discussion, '), (10, 1, 5, 1, 19, 0, 0, 'Discussion, '), (11, 1, 5, 2, 19, 0, 0, 'Discussion, '), (12, 1, 5, 4, 19, 0, 0, 'Discussion, '), (13, 1, 5, 6, 7, 0, 0, 'Discussion, '), (14, 1, 5, 7, 19, 0, 0, 'Discussion, '), (15, 1, 5, 2, 12, 0, 0, 'Discussion, '), (16, 1, 5, 3, 12, 0, 0, 'Discussion, '), (17, 1, 5, 4, 12, 0, 0, 'Discussion, '), (18, 1, 5, 5, 12, 0, 0, 'Discussion, '), (19, 1, 5, 6, 12, 0, 0, 'Discussion, '), (20, 1, 5, 7, 12, 0, 0, 'Discussion, '), (21, 1, 5, 3, 19, 0, 1, 'Discussion, '), (22, 1, 5, 5, 19, 0, 1, 'Discussion, '), (23, 1, 5, 7, 10, 0, 0, 'Discussion, Women, '), (24, 1, 4, 7, 8, 0, 0, 'Discussion, Men, '); Here goes #4 -- -- Table structure for table `day` -- CREATE TABLE IF NOT EXISTS `day` ( `id` int(3) NOT NULL auto_increment, `day` varchar(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- -- Dumping data for table `day` -- INSERT INTO `day` (`id`, `day`) VALUES (1, 'Sunday'), (2, 'Monday'), (3, 'Tuesday'), (4, 'Wednesday'), (5, 'Thursday'), (6, 'Friday'), (7, 'Saturday'); Finally #5: -- -- Table structure for table `area` -- CREATE TABLE IF NOT EXISTS `area` ( `id` int(3) unsigned NOT NULL auto_increment, `acronym` varchar(15) NOT NULL, `name` varchar(50) NOT NULL, `phoneline` varchar(15) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ; -- -- Dumping data for table `area` -- INSERT INTO `area` (`id`, `acronym`, `name`, `phoneline`) VALUES (1, 'ARVANA', 'Arkansas River Valey Area', '800-338-8750'), (2, 'CAACNA', 'Central Arkansas Area', '501-373-8683'), (3, 'CRANA', 'Crowley''s Ridge Area', '800-338-8750'), (4, 'FUANA', 'Foothills Unity Area', '800-338-8750'), (5, 'GFLANA', 'Greers Ferry Lake Area', '800-338-8750'), (6, 'NWA', 'Northwest Arkansas Area', '800-815-3302 Ar'), (7, 'OASCNA', 'Ozark Area', '800-338-8750'), (8, 'ORACNA', 'Ouachita River Area', '800-338-8750'), (9, 'TANA', 'Texarkana Area', '800-338-8750'), (10, 'Loner ', 'Loner Group', '800-338-8750'); Now this is the same as above for my queries: <?php $sql_group_info = "SELECT * FROM group_info ORDER BY groupname"; $group_query = mysql_query($sql_group_info) or die(mysql_error()); while ($group_data = mysql_fetch_array($group_query)){ $groupname= $group_data['groupname']; $area_id = $group_data['area_id']; $group_id = $group_data['id']; $sql_area = "SELECT * FROM area WHERE id = '$area_id'"; $area_query = mysql_query($sql_area) or die(mysql_error()); $area_data = mysql_fetch_array($area_query); $area = $area_data['acronym']; $phoneline = $area_data['phoneline']; echo "<b><table><tr><td style=\"width:250px;color:red;vertical-align:top;\"><b>" .$groupname . "</td></b><td style=\"width:250px;text-align:right;\">Area Afiliation:<b>" . $area . "</b><br /></td></tr></table>"; //start 1st nested while loop $sql_location = "SELECT * FROM location WHERE group_id = $group_id"; $sql_result_location = mysql_query($sql_location) or die(mysql_error()); while ($result_location = mysql_fetch_array($sql_result_location)){ $location_id = $result_location['id']; $address = $result_location['address']; $city = $result_location['city']; $state = $result_location['state']; $zip = $result_location['zip']; $map = $result_location['map']; echo "<span style=\"color:blue;\">" .$address . "</span><br />" . $city . ", " . $state . " " . $zip . " " . $map . "<br />"; //start 2nd nested while loop $sql_meeting = "SELECT * FROM day_time WHERE location_id = '$location_id'"; $result_meeting = mysql_query($sql_meeting) or die(mysql_error()); while ($data_meeting = mysql_fetch_array($result_meeting)){ $day_id = $data_meeting['day_id']; $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); if ($day_id == 1){ $day = $days[0]; } elseif ($day_id == 2) { $day = $days[1]; } elseif ($day_id == 3) { $day = $days[2]; } elseif ($day_id == 4) { $day = $days[3]; } elseif ($day_id == 5) { $day = $days[4]; } elseif ($day_id == 6) { $day = $days[5]; } elseif ($day_id == 7) { $day = $days[6]; } echo "<b>$day</b><br />"; $sql_meeting2 = "SELECT * FROM day_time WHERE location_id = '$location_id' AND day_id = '$day_id' ORDER BY hour"; $result_meeting2 = mysql_query($sql_meeting2) or die(mysql_error()); while($data_meeting2 = mysql_fetch_array($result_meeting2)){ $hours = $data_meeting2['hour']; $minute = $data_meeting2['minute']; $open = $data_meeting2['open']; $format = $data_meeting2['format']; if ($hours >= 12){ $am = "PM"; } else { $am = "AM"; } if ($hours > 12) { $hour = ($hours - 12); } elseif ($hours < 13) { $hour = $hours; } if ($minute == 0){ $minutes = "00"; } else { echo $minute; } if ($open == 1){ $opens = "Open"; } else { $opens = "Closed"; } $time = $hour . ":" . $minutes . $am; echo "<table width=\"650px\"> <tr><td width=\"250px\">$time</td><td>$opens:$format</td></tr>"; echo "</table>"; }//end 4th while }//end 3rd while }//end 2nd while }//end 1st while ?> OK my goal is to call data from these tables that will allow me to display rows with city(once),then, groupname, then, location for that groupname (some will have more than one location), then, days, then times with open or closed and formats. Hopefully it will show kinda like a hierarchy. <b>City</b><br/> Groupname<br/> Day<br/> time and format<br/> next day<br/> time and format<br/> maybe next day<br/> time and format<br/> <b>Next City</b> Groupname<br/> Day<br/> time and format<br/> next day<br/> time and format<br/> maybe next day<br/> time and format<br/> next Groupname<br/> Day<br/> time and format<br/> next day<br/> time and format<br/> maybe next day<br/> time and format<br/> I know this is asking a lot. The query I have now shows me something very simular but for some reason it has a couple of duplicates. I do not see the duplicates in any individual tables, maybe it could be the way I set up my tables. This query is the hard one for me. If I get this one done the others will be only searching by groupname, city or area only. Thanks for any helpful reply. Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-942462 Share on other sites More sharing options...
xtopolis Posted October 23, 2009 Share Posted October 23, 2009 Hey, So I've been looking at this for awhile, but have run out of time to work on it. First off, thanks for posting the dumps, it makes it really easy to see and test what you're doing. The things I've noticed are that your database relationships are kinda ... murky. You use semi ambiguous column names (id) which aren't horrible, but make it a bit unclear for someone coming into it. Consider renaming them to match their table name (id -> location_id... etc). Secondly, while trying to follow your desired output: city, group, location..etc.. it made me feel your tables aren't organized as well as I thought (read: normalized). You may want to break out the things such as city/state/zip, and condense other things (get rid of day table, add a dayname column to day_time). Looking at your relationship for group_info -> area , I think that it should have a better hierarchy. A group should belong to a location, and a location could belong to an area. Currently a group is directly related ( in your table ) to an area, but a location is related to a group. (I'm going by how the columns reference each other). As I said, I didn't have time to get to a workable solution, but you can take a look at something crazy I was testing with using JOINs so that you may further understand their power. $sql = "SELECT l.city as city, g.groupname as groupname, l.address as addr, g.id as gid, d.day, dt.hour, dt.minute, dt.format as format FROM location l JOIN group_info g ON(l.group_id = g.id) JOIN day_time dt ON(g.id = dt.group_id) JOIN day d ON(dt.day_id = d.id) ORDER BY l.city ASC, d.id ASC, dt.hour ASC"; $result = mysql_query($sql); while(list($city, $groupname, $addr, $lid, $gid, $day, $hour, $minute, $format) = mysql_fetch_array($result)) { $info[$city][$groupname][$lid][$addr][$day][$hour] = $format; } echo '<pre>'; print_r($info); echo '</pre>'; At this point I would suggest stopping your development and drawing it out on paper. Write down what you have: "groups", "locations", "days", "times", etc and see how they might all fit together. This will help you re-design your database a bit more clearly. Also, I could be wrong about my suggestions; I am a little rusty. You may want to wait and see what fenway/kickstart or another more experienced MySQL developer has to say. Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-942572 Share on other sites More sharing options...
jmr3460 Posted October 24, 2009 Author Share Posted October 24, 2009 Thanks for your effort xtopolis!!! I am going to take your advise and do a little redesign on the database. I will get rid of the day table. I just found the WEEKDAY() and If it works on the query to make sure that the days list from Sunday to Saturday That is all I needed. As far as the AREA table. Area is not so much a geographical thing. It is a service committee and the groups make the decision whether they want to participate in this committee or not. There is a selection in area called Loner. Anyway I am also going to change id in group_info to group_id, id in location to location_id and so on. Oh yea I will try and simplify hour and minute to time and see if I can find a way to chronologically display time with AM or PM. I wanted to say thanks again for the query you sent me. I think I am starting to see the JOIN in my head but I am going to study more. When I plugged in your query I think it might have worked. The pre tags through me off a little but could see the information as arrays and that was different. I also got Notice: Undefined offset 8 on line ?. I don't want to have to get back into this database and do a redesign after it is so to say working and has 75+ groups and their information in it. I am hoping to eventually let these groups do their own updates. I think the more work I do today the less I will have to do a year or so from now. If there is anything else you see that might help Please let me know. I am not going to set this topic as solved so when I have something I can post it here. As long as the admins allow it. Thanks Again!!! Quote Link to comment https://forums.phpfreaks.com/topic/178172-day-query-is-giving-me-duplicate-results/#findComment-943290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.