|
Posted by Schraalhans Keukenmeester on 06/17/07 10:57
At Sun, 17 Jun 2007 01:45:43 -0700, Shutey let h(is|er) monkeys type:
> 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
Does the behaviour change when you fetch associative arrays only?
(mysql_fetch_assoc())
Extract() will work with numerically indexed arrays only if
EXTR_PREFIX_ALL or EXTR_PREFIX_INVALID are used as extract-type. I would
not recommend stuffing the symbol table by using extract on each row. I
don't know how many fields each record has, I'd either reference the
required row elements directly or use
list ($field1, $field2, ..., $fieldN)= $row;
--
Schraalhans Keukenmeester - schraalhans@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]
"strcmp('apples','oranges') < 0"
[Back to original message]
|