SirChick Posted October 22, 2007 Share Posted October 22, 2007 I have a selection box showing a list of choices from a query but my page is completely blank and it isn't showing up on the page...also the rest of the form is also not showing and I do not know what could be causing it... here is the form : <form name="" method="POST" action="businesslondonstage2.php" enctype="text/plain" id="Form1"> <?php //generates a list box to display the rows of available business $CountNames = ("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE C < 3"); $findbusinessresult = mysql_query($CountNames) or die(mysql_error()); echo '</br></br><center><select name="businesslist" size=10>"></center>'; Echo'<option value =""><b><u>Business Types</b></u></option>'; while($row = mysql_fetch_array($findbusinessresult)) { echo "<option value=\"{$row['BusinessType']}\">{$row['BusinessType']}</option>"; } echo '</select>'; ?> <input type="submit" id="Button1" name="Button1" value="Submit" style="position:absolute;left:358px;top:215px;width:75px;height:45px;z-index:1"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="" style="position:absolute;left:466px;top:232px;z-index:2"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/ Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 It could be because of your br's </br> should be <br /> Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375494 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 I wouldn't see how ... tried it and no change.. ive always used </br> rather than <br/> dont think theres a difference Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375502 Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 And your center codes.. echo '<br /><br /><center><select name="businesslist" size=10>"'; echo'<option value =""><b><u>Business Types</b></u></option>'; while($row = mysql_fetch_array($findbusinessresult)) { echo "<option value=\"{$row['BusinessType']}\">{$row['BusinessType']}</option>"; } echo '</select></center>'; Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375505 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 Again i do not think its a html problem as the html isnt even showing in the page source, its a php problem which is jumping out due to an error but then not displaying an error. Im almost sure of it but can't think what it is. Most likely my query but I'll see if any can see a problem with my query.... Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375506 Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 Ok, Ill rewrite your code then: <?php //generates a list box to display the rows of available business $findbusinessresult = mysql_query("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE C < 3") or die(mysql_error()); while($row = mysql_fetch_array($findbusinessresult)) { $option .= "<option value=\"{$row['BusinessType']}\">{$row['BusinessType']}</option>"; } ?> <form name="" method="POST" action="businesslondonstage2.php" enctype="text/plain" id="Form1"> </br></br><center><select name="businesslist" size=10>"></center> <option value =""><b><u>Business Types</b></u></option> <?="$option"; ?> </select> <input type="submit" id="Button1" name="Button1" value="Submit" style="position:absolute;left:358px;top:215px;width:75px;height:45px;z-index:1"> <input type="checkbox" id="Checkbox1" name="Checkbox1" value="" style="position:absolute;left:466px;top:232px;z-index:2"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375509 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 Same result.. SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE C < 3 Do you think queries would know what C is or should it be $C ? :S Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375511 Share on other sites More sharing options...
phpQuestioner Posted October 22, 2007 Share Posted October 22, 2007 are you connecting to your db; because I do see where your connecting Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375515 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 i have a global include which deals with all that. Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375517 Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 are you connecting to your db; because I do see where your connecting Then it should show an error Same result.. SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE C < 3 Do you think queries would know what C is or should it be $C ? :S No, make sure you check your cases, 'c' is completely different too 'C'. Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375519 Share on other sites More sharing options...
phpQuestioner Posted October 22, 2007 Share Posted October 22, 2007 yes it should; but you have to connect to you database to get content from it maybe the brackets in your echo is causing a problem Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375521 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 umm is the C used correctly in the query ? i made a new php script with the same query to test it and now it shows the problem: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE C < '3'' at line 1 were getting there but still not know what i got wrong =/ Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375541 Share on other sites More sharing options...
SirChick Posted October 22, 2007 Author Share Posted October 22, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375595 Share on other sites More sharing options...
lewis987 Posted October 22, 2007 Share Posted October 22, 2007 you need to re-write your whole code mate, there is not way in hell you are going to make that run, the query is f****d Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375686 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 why whats wrong with it? Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376218 Share on other sites More sharing options...
ballhogjoni Posted October 23, 2007 Share Posted October 23, 2007 have you tried SELECT count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE BusinessType < 3 Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376225 Share on other sites More sharing options...
pocobueno1388 Posted October 23, 2007 Share Posted October 23, 2007 Your WHERE clause needs to come before your GROUP BY. SELECT *, count(BusinessType) as C FROM `businesses` WHERE C < 3 GROUP BY BusinessType WHERE C < 3 That doesn't quite make sense to me. What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376226 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 Ok this is an example of what it's meant to do . Say theres a table with field name "name" and all the records are these: 1. cheese 2. cheese 3. bacon 4. cheese 5. bacon 6. lettuce 7. bacon 8. orange 9. orange The query is suppose to find all records where by there is less than 3 of the same field value...as shown 6. lettuce 8. orange and 9. orange would be the only one that would load in this case hope this helps. MadTechie wrote the query for me as I was having difficulty working out how to get a query to do this I tried your query poco but it says : Unknown column 'C' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376267 Share on other sites More sharing options...
pocobueno1388 Posted October 23, 2007 Share Posted October 23, 2007 Why didn't you continue with your last post about this? I thought MadTechie solved it with this solution <?php $CountNames = ("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType HAVING C < 3"); $findbusinessresult = @mysql_query($CountNames) or die(mysql_error()); $row = mysql_fetch_assoc($findbusinessresult); //<--missing echo $row['BusinessType']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376271 Share on other sites More sharing options...
SirChick Posted October 23, 2007 Author Share Posted October 23, 2007 Yeh i had that, and it did work for a bit then it stopped working saying it cannot find the field but it's definitely there and its case matched. Unknown column 'BusinessType' in 'field list' [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376273 Share on other sites More sharing options...
pocobueno1388 Posted October 23, 2007 Share Posted October 23, 2007 The code isn't just going to start and stop working whenever it wants, something had to have changed to cause it to stop working. I would help you more if I could, but I'm not an expert at MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376278 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.