Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/
Share on other sites

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>';

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375505
Share on other sites

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....

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375506
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375509
Share on other sites

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'.

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375519
Share on other sites

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 =/

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-375541
Share on other sites

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'

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376267
Share on other sites

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'];
?>

Link to comment
https://forums.phpfreaks.com/topic/74323-select-box-with-query/#findComment-376271
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.