473,785 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pull Down Menu Query

I'm trying to populate the pulldown menus of a single input form
through queries from a single table. The three columns are 'name',
'type', and 'status'. The name table runs to approx row 23, the type,
to row 8, and status, row 9. . I'm using the following code to
populate the form pulldown menus::

<?php
$query = "SELECT DISTINCT status
FROM $table";
$result = mysql_query($qu ery);
$number = mysql_numrows($ result);

for ($i=0; $i<$number; $i++) {
$status = mysql_result($r esult,$i,"statu s");
print "<option value=\"$status \">$status</option>";
}

mysql_close();
?>
The interesting portion here is that 'name' only allows a single blank
space on the pulldown as I had expected and so does 'status'. 'Type'
on the other hand, shows 2 blank spaces on the pulldown menu so what's
with that? Is there some sort of 'end of file marker' that I should
be inserting to the database columns to get this to read correctly?
TIA
Jul 26 '07 #1
5 1721
On 26.07.2007 09:51 Toby A Inkster wrote:
cover wrote:
>$query = "SELECT DISTINCT status
FROM $table";

Most databases optimise GROUP BY better than DISTINCT. Generally speaking,
if you can avoid DISTINCT, you should: it forces the database engine to
retrieve rows and then discard them, whereas often, especially with
well-indexed columns, the engine will be able to do smarter things with
GROUP BY.
Don't know about "most" ones, mysql docs explicitly says they're equivalent

http://dev.mysql.com/doc/refman/5.0/...imization.html
--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Jul 26 '07 #2
gosha bine wrote:
Don't know about "most" ones, mysql docs explicitly says they're equivalent
http://dev.mysql.com/doc/refman/5.0/...imization.html
It says that SELECT DISTINCT and GROUP BY *usually* end up generating the
same execution plan, so there won't be a performance difference.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 36 days, 13:07.]

Cryptography Challenge
http://tobyinkster.co.uk/blog/2007/0...pto-challenge/
Jul 27 '07 #3
On 27.07.2007 11:46 Toby A Inkster wrote:
gosha bine wrote:
>Don't know about "most" ones, mysql docs explicitly says they're equivalent
http://dev.mysql.com/doc/refman/5.0/...imization.html

It says that SELECT DISTINCT and GROUP BY *usually* end up generating the
same execution plan, so there won't be a performance difference.
Pretending that you cannot read is probably the worst defense you could
come up with. ;)

--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Jul 27 '07 #4
On 27 Jul, 11:31, gosha bine <stereof...@gma il.comwrote:
On 27.07.2007 11:46 Toby A Inkster wrote:
gosha bine wrote:
Don't know about "most" ones, mysql docs explicitly says they're equivalent
http://dev.mysql.com/doc/refman/5.0/...imization.html
It says that SELECT DISTINCT and GROUP BY *usually* end up generating the
same execution plan, so there won't be a performance difference.

Pretending that you cannot read is probably the worst defense you could
come up with. ;)

--
gosha bine

makrell ~http://www.tagarga.com/blok/makrell
php done right ;)http://code.google.com/p/pihipi
But it is you who cannot read!

The manual does NOT (neither explicitly not implicitly) say that GROUP
BY and DISTINCT are equivalent.

What it does say is:

"In most cases, a DISTINCT clause can be considered as a special case
of GROUP BY."

And it then says:

"For example, the following two queries are equivalent: ..."

The phrase "In most cases" implies that they are not equivalent. If
they were it would say "In all cases".

Jul 27 '07 #5
On Thu, 26 Jul 2007 08:51:22 +0100, Toby A Inkster
<us**********@t obyinkster.co.u kwrote:

<snip>

Hey, looks like some great ideas and I'll give them a try. Thank you
very much. :-)

Jul 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1773
by: Phillip Russell | last post by:
Is there a way for PHP to see what is selected in a pull-down menu. So that i can use a switch statement to display certain information. If not how can I combine javascript with it to work.
5
4778
by: Glenn Mulno | last post by:
Hi, I am trying to create a report page for several teams. Each team runs the same reports but the reports use different values. For a while this was getting insane everytime I updated the queries I had to change them in many places. Then I started using server side includes to keep me from changing some items in multiple places. There is still some double (quadruple) updating going on though when I make
7
4603
by: jt | last post by:
I am new to Javascript and I am having problems with loading a pull down menu. I get this error: javax.servlet.ServletException: No data found It will list the items just fine if I just list the items without using the select & option tags. I would like to know why I am getting an error with the following statement:
1
1506
by: NEUE | last post by:
Hello, I'm trying to have a layer appear on top of a simple pull-down menu, but in IE6 the pull-down menu always appears on top. Even if I put the pull-down in a layer under the other layers, it shows on top. On Firefox and all Mac browsers is fine. Any way around this? Thanks NF
5
5377
by: judiphuongtu | last post by:
I am trying to create an input form with a pull-down menu that allows a user to add an item to the pull-down. I don't want the page to refresh when I refresh the pull-down since there's entries on the form already. Please help! Thanks. jptu
2
3103
by: Keith Burns | last post by:
Hi, I have seen two entries in the archives for this topic: 1. Uses hypertext, not a pulldown menu to feed parameters back to the python CGI 2. The other actually used Java. Is there a way using Python for CGI such that when a user selects an item from one pull down menu (ie FRUIT or VEGETABLE or MEAT) that another pull
1
1692
by: dkimbrell | last post by:
Hi there, I'm very novice to web design. I'm trying to make a pulldown menu, but the formatting keeps getting screwed up when you roll the mouse over it. Please see www.boundarysys.com for what I'm talking about. Before the mouse touches the pulldown, the vertical height of the menubar is perfect. As soon as the mouse rolls over it, it expands to about twice the height.
21
2902
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields. Example: Database name: sp Table: importer Field names: imp_code, imp_name, imp_address, imp_tel
5
4007
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make Fields Names: countrycode, make
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.