JTapp Posted October 14, 2009 Share Posted October 14, 2009 Everything seemed to be working fine. I have a table, it alphabetically lists a bunch of cities and relivant city data. However, I found out that the city is showing up only one time when I have can have more than one rows with that City name.. I.e. - I should have 15 rows that are all "Jacksonville" but I am only seeing one. I guess my code is eliminating what it thinks are duplicates? Here is my code (I renamed field names for communication purposes) $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("companies",$dbhandle) or die("Could not select companies"); $query = mysql_query("SELECT* FROM companies GROUP BY City"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["Email"]; $variable2=$row["WEB"]; echo "<tr bgcolor=\"#dddddd\"><td><center>"; echo $row["City"]; echo ($variable2 != '') ? "<a href=\"$variable2\"></br> Website</a>" : ''; echo ($variable1 != '') ? "<a href=\"mailto:$variable1\">Email</a>" : ''; echo ltrim($row[""], '0'); }?> Link to comment https://forums.phpfreaks.com/topic/177691-please-help-should-be-a-simple-fix-driving-me-nuts/ Share on other sites More sharing options...
mrMarcus Posted October 14, 2009 Share Posted October 14, 2009 perhaps your GROUP BY is dong it? you try the same query without? Link to comment https://forums.phpfreaks.com/topic/177691-please-help-should-be-a-simple-fix-driving-me-nuts/#findComment-936913 Share on other sites More sharing options...
Calver Posted October 14, 2009 Share Posted October 14, 2009 Did you want to sort by City - 'ORDER BY City' instead of 'GROUP BY City' ? Link to comment https://forums.phpfreaks.com/topic/177691-please-help-should-be-a-simple-fix-driving-me-nuts/#findComment-936919 Share on other sites More sharing options...
JTapp Posted October 14, 2009 Author Share Posted October 14, 2009 Worked like a charm. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/177691-please-help-should-be-a-simple-fix-driving-me-nuts/#findComment-936939 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.