|
Posted by Jerry Stuckle on 06/17/07 12:32
Shutey wrote:
> On 17 Jun, 12:51, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Shutey wrote:
>>> On 17 Jun, 09:31, Georgi Naumov <gonau...@gmail.com> wrote:
>>>> Shutey :
>>>>> I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on
>>>>> a fast XP pro PC, I have a form which requires 5 dropdowns populated
>>>>> with indentical values. I extract the values using SQL and populate 2
>>>>> variables and use a for-next loop to create the dropdown. The dropdown
>>>>> contains some 310 items! It works beautifully if I have 1 or 2
>>>>> dropdowns but as soon as I add more it partially creates the 3rd and
>>>>> just stops until it times out!
>>>>> All 5 work because I have altered their positions but it always stops
>>>>> part way through creating the 3rd dropdown.
>>>>> I tried an alternative method by doing away with the variables and
>>>>> constructing the dropdowns with a 'while' statement reading through
>>>>> the results of my SQL and got exactly the same problem only 2 and a
>>>>> bit dropdowns.
>>>>> Stopping it running after a few seconds or several minutes makes no
>>>>> difference, it seems to reach a certain point and just stop - no error
>>>>> messages or anything!
>>>>> I have tried increasing the resourses in my php.ini file but this also
>>>>> made no difference.
>>>>> Can anyone suggest an alternative or a fix?
>>>>> Thanks
>>>> .........................................................................................
>>>> Can you paste same code ?- Hide quoted text -
>>>> - Show quoted text -
>>> Here's the code I am currently using, there are 4 more identical
>>> 'name=option2, 3, 4 and 5' but otherwise the same.
>>> $qry = 'SELECT field1, field2 ';
>>> $qry .= 'FROM database ';
>>> $qry .= 'ORDER BY field1, field2;';
>>> echo '<table border="0" cellpadding="2" cellspacing="0"><tr>';
>>> echo "<td>Label 1:</td>";
>>> echo "<td><select name='option1' size='1'>";
>>> echo "<option value=''></option>";
>>> $x = -1;
>>> $res = mysql_query($qry) or die("Query failed);
>>> while($row = mysql_fetch_array($res))
>>> {
>>> extract($row);
>>> $x+=1;
>>> $sel = '';
>>> if ($field1 == $ref_variable1) $sel = 'SELECTED';
>>> echo "<option value='" . $field1 . "' $sel>" . $field2 . "</
>>> option>";
>>> }
>>> echo "</select></td>";
>>> echo "</tr></table>";
>>> Thanks for your interest
>> 310 items in a single dropdown is a lot - and 5 dropdowns with the same
>> items is going to generate a lot of HTML. Not what I would call real
>> user-friendly, but it should still work.
>>
>> You've shown the code for one of the dropdowns, which looks good. But
>> what about the other 4? How do you generate them, also?
>>
>> You could also try the following - it will be a little more efficient
>> than your existing code. Not that there's anything wrong with your
>> existing code, but this might do something a little different:
>>
>> echo '<table border="0" cellpadding="2" cellspacing="0"><tr>';
>> echo "<td>Label 1:</td>";
>> echo "<td><select name='option1' size='1'>";
>> echo "<option value=''></option>";
>> $x = -1;
>> $res = mysql_query($qry) or die("Query failed);
>> while($row = mysql_fetch_array($res))
>> {
>> $x++; // Do you actually need $x?
>> if ($row['field1'] == $ref_variable1) // Just use the array value
>> $sel = ' SELECTED';
>> else
>> $sel = '';
>> echo "<option value='" . $row['field1'] . "'$sel>" . $row['field2'] .
>> "</option>";
>> }
>> echo "</select></td>";
>> echo "</tr></table>";
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks for this Jerry, I can see where you are coming from and you are
> right it does look more efficient but alas resulted in the same issue,
> 2 and a half dropdowns before stopping.
>
> The $x method was born out of my first attempt, the code I posted was
> my second. Initially I started by SQLing the data into a 2 dimentional
> array and then looping through them 5 times but curiously this stopped
> at exacting the same point within the 3rd dropdown as the code you
> have seen and with the changes you have suggested.
>
> As you say the 5 * 310 item dropdowns are somewhat top heavy but I
> have a changing group (currently 310 and likely to grow) from which
> individuals can choose up to 5 from. I could have one dropdown and
> allow multiple choice but this is on an Intranet for (shall we say)
> heavy handed individuals and I only have 1/3 of a 1280 x 800 screen to
> fit the form on!
>
> Thanks for you suggestion.
>
Well, I'm wondering if this is a server issue or a browser issue? I
don't think I've ever tried a page with that many options in dropdowns.
the fact it failed in exactly the same place leads me to believe it
might be a problem with the browser. The other option is maybe it's a
problem with the web server itself - but I wouldn't think so.
What happens if, instead of populating dropdowns, you just echo the
contents to the window. If it's a server issue I would expect it to
fail in about the same place. But if it's a browser issue I would
expect it to display the values.
IOW - just comment out the echo for the select tag and don't write the
option tags - just the two values. As far as PHP is concerned, the code
will be identical, but the browser will see something much different.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|