473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

very simple drop-down list...

max
Hi! I'm having a problem with a very simple drop-down list since the
page comes out with no elements in the drop-down but giving no errors.
This is the code:
<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
..mysql_error());

while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line['year']."></OPTION>"); }
?>
</select>
</form>

The connection with the DB is established and working..
Thanks for your help!!
Sep 18 '05 #1
20 2268
<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
.mysql_error());


View the HTML source - any error message will be invisible via your
browser because you are in the middle of specifying a form and dropdown
list.

---
Steve

Sep 18 '05 #2
I noticed that Message-ID: <lo******************@twister1.libero.it>
from max contained the following:
print ("<OPTION value=".$line['year']."></OPTION>"); }


Duh...
print ("<OPTION>".$line['year']."</OPTION>"); }

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sep 18 '05 #3
max
Steve probably wrote the following stuff on 19/09/2005 1.14:
<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
.mysql_error());

View the HTML source - any error message will be invisible via your
browser because you are in the middle of specifying a form and dropdown
list.


ok, this is the html output source :

<form name="year_search_form" method="get" action="results.php">
<select name="select_year" id="select_year">

</select>
<input name="submit" type="submit" class="search_button" value="Search">
</form>

it looks like it doesn't get anything...
I tried a simple loop on the same page and it outputs the data fine...
Sep 18 '05 #4
max
Geoff Berrow probably wrote the following stuff on 19/09/2005 1.17:
I noticed that Message-ID: <lo******************@twister1.libero.it>
from max contained the following:

print ("<OPTION value=".$line['year']."></OPTION>"); }

Duh...
print ("<OPTION>".$line['year']."</OPTION>"); }


tried as you said but still nothing...
Sep 18 '05 #5
Please post a couple of lines of the html source in the problem area.
Geoff's change looks spot on to me.

Sep 19 '05 #6
<select name="select_year" id="select_year">

</select> it looks like it doesn't get anything...
I tried a simple loop on the same page and it outputs the data fine...

Wait... print is not a function! Remove the parentheses, and try this:

while ($line = mysql_fetch_array($result))
{
print "<OPTION
value=".$line['year'].">".$line['year']."</OPTION>";
}

---
Steve

Sep 19 '05 #7
<---- Got plastered by that one!

Sep 19 '05 #8
I noticed that Message-ID:
<11*********************@f14g2000cwb.googlegroups. com> from Steve
contained the following:
Wait... print is not a function! Remove the parentheses


True but that's not the problem. There are obviously no rows returned
by the query.

What I usually do is echo the SQL and paste it into phpMyadmin to check
the query.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sep 19 '05 #9
Instead of:

<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
..mysql_error());
while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line['year']."></OPTION>"); }
?>

Try this:

<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
..mysql_error());
$num_rows = mysql_num_rows($result);

for ($count = 0; $count < $num_rows; $count++) {
$line = mysql_fetch_array($result);
print ("<OPTION
value=".$line['year'].">".$line['year']."</OPTION>"); }
?>

Sep 19 '05 #10
Geoff Berrow probably wrote the following stuff on 19/09/2005 8.29:
I noticed that Message-ID:
<11*********************@f14g2000cwb.googlegroups. com> from Steve
contained the following:

Wait... print is not a function! Remove the parentheses

True but that's not the problem. There are obviously no rows returned
by the query.

What I usually do is echo the SQL and paste it into phpMyadmin to check
the query.


thanks for your help guys, i tried to echo to output on the page without
using the "html select tag" and it works fine showing all the years..
But still it doesn't display anything in the dropdown menu.. :-\
Sep 19 '05 #11
Darkstar 3D probably wrote the following stuff on 19/09/2005 1.58:
Please post a couple of lines of the html source in the problem area.
Geoff's change looks spot on to me.


ok, well I put this:

<form name="year_search_form" method="get" action="results.php">
<select name="select_year" id="select_year">
<?php
$num_rows = mysql_num_rows($result);
for ($count = 0; $count < $num_rows; $count++) {
$line = mysql_fetch_array($result);
print ("<OPTION value=".$line['year'].">".$line['year']."</OPTION>");}
?>
</select>
<input name="submit" type="submit" class="search_button" value="Search">
</form>
======
while just under it i displayed this to see if the sql query worked:
======
<?php
$line = mysql_fetch_array($result);
echo($line['year']);
while ($line = mysql_fetch_array($result)) {
print ("<br>".$line['year']); }
?>

and it outputs correctly the years contained in the table..
Thanks for your time!
Sep 19 '05 #12

Yep quiet right, had no PHP to test with before, but now I do and this
makes no difference.

OP says he tried dumping the query results and got what he expected, so
must have used different queries in each case (or DB content has
changed.)

---
Steve

Sep 19 '05 #13
max probably wrote the following stuff on 19/09/2005 1.04:
Hi! I'm having a problem with a very simple drop-down list since the
page comes out with no elements in the drop-down but giving no errors.
This is the code:
<form name="year_search_form" method="post" action="results.php">
<select name="select_year" id="select_year">
<?
$query="SELECT * FROM table ORDER BY year";
$result = mysql_query($query) or die ("Error in query: $query. "
.mysql_error());

while ($line = mysql_fetch_array($result)) {
print ("<OPTION value=".$line['year']."></OPTION>"); }
?>
</select>
</form>

The connection with the DB is established and working..
Thanks for your help!!

Fixed it! The main problem were the quotes :

print ('<OPTION value="'.$line['year'].'">'.$line['year'].'</OPTION>');

here it works.
Thanks!
Sep 19 '05 #14
I noticed that Message-ID: <Ig******************@twister1.libero.it>
from mars contained the following:
Fixed it! The main problem were the quotes :

print ('<OPTION value="'.$line['year'].'">'.$line['year'].'</OPTION>');


Personally I'd do it like this

print "<OPTION value='".$line['year']."'>".$line['year']."</OPTION>";
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sep 19 '05 #15
***********
(I am sorry to post in this fashion but I am trying to post this
message since the past three hours, but am unable to, inspite of the
fact that I have been regularly posting to at least five groups every
day and suddenly everything seems to stop working - Google groups also
shows me a confirmation of the post but somehow my posts do not appear
- neither am I blocked or any such thing)
***********

1)I get startup error messages:
"cannot load c:\php\php_curl.dll - the specified file cannot be found"
although the file is very much there at exactly that location
Not only for this file but for many extension files like php_mysql.dll,
php_oracle.dll, php_mssql.dll, php_exif.dll etc.

2)the extensions_dir setting is "c:\php" without an ending backslash.

3)The php.ini file is residing at c:\php

4)The php.ini file in c:\windows has all extensions disabled so it does
not look as though that php.ini file is the source of the messages

5)There is a extension entry for php_win32api.dll which also gives a
not found error.
Is it the older version of php_win32std.dll, php_win32service.dll and
php_win32scheduler.dll files which are present but
their names are not there by default in the php.ini ?

************************************************** ************************************************
6)How do I debug PHP like you can debug Java in Eclipse or NetBeans and
C/C++ in MS Visual Studio?
************************************************** ************************************************

7)database access through odbc works.

8)How do I install PHP as both a CGI extension under Apache 2.0.5x and
as a module (php5apache2.dll with a LoadModule in httpd.conf)

Sep 19 '05 #16
test post please ignore

Sep 19 '05 #17
In article <9h********************************@4ax.com>,
Geoff Berrow <bl******@ckdog.co.uk> wrote:
print "<OPTION value='".$line['year']."'>".$line['year']."</OPTION>";


Or:

printf("<OPTION value=\"%s\">%s</OPTION>",$line['year'],$line['year']);

--
http://yosemitenews.info/
Sep 19 '05 #18
Am I to understand that it is working now? Did you just modify the 2nd
query and place it in the form code?

By HTML source, I meant what you are getting as a result in browser.

Sep 19 '05 #19
Darkstar 3D probably wrote the following stuff on 20/09/2005 1.22:
Am I to understand that it is working now? Did you just modify the 2nd
query and place it in the form code?


now it is working with the code that I posted in the other message (the
problem was caused by myself messing up with single/double quotes). :-)
Sep 20 '05 #20
Why not just change the print for an echo ?

Sep 23 '05 #21

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

Similar topics

42
by: Steven O. | last post by:
I am seeking some kind of tool that I can use for GUI prototyping. I know how to use Visual Basic, but since a lot of software is being coded in Java or C++, I'd like to learn a Java or C++ -based...
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
4
by: Bruce D | last post by:
I have this simple subquery...and I get an error when I try to run it?? SELECT ZipID FROM testzip WHERE ZipID <> ( SELECT ZipID FROM Zip ) any ideas?
1
by: David Lawson | last post by:
The line indicated below from my php script is very slow (about 10 seconds). I have this field indexed so I thought that it would be much faster. Could someone tell me what might be wrong? I'm also...
6
by: Jean-Marc Blaise | last post by:
Hi Folks, I have a SQL proc that does the following below (this is a MDC rollout; I drop indexes because YEAR_NUM which is a dimension, is part of the unique index, and the optimizer decides to...
20
by: Brian Tkatch | last post by:
An ORDER BY a simple-integer inside a FUNCTION, results in SQL0440N, unless the FUNCTION expects an INTEGER as its parameter. For example: DECLARE GLOBAL TEMPORARY TABLE A(A CHAR(1)) INSERT INTO...
16
by: lovecreatesbeauty | last post by:
`Writing C code is very simple', one guy related to my work said. I'm not sure whether he is an expert or not. What he said about C programming like this can't convince me. I think there should be...
5
by: sesar | last post by:
How can I impement drag&drop for simple 'dialog base' application... I want to drag&drop txt file and load the text to variable
1
by: eBob.com | last post by:
The dirt simple function below hangs up the thread it is executing on. Private Function PurifyTelnum(ByVal telnum As String) As String ' drop trailing "&nbsp;" Dim nbspIndex As Integer =...
126
by: jacob navia | last post by:
Buffer overflows are a fact of life, and, more specifically, a fact of C. All is not lost however. In the book "Value Range Analysis of C programs" Axel Simon tries to establish a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.