Jump to content

a to z in combo box


brown2005

Recommended Posts

echo"    <select name='a' class='text'>";
echo" <option value=''>&nbsp;</option>";

$current_price = "";

while ($row = mysql_fetch_array($query, MYSQL_ASSOC))
{

if($row['a'] != $current_price)
{

echo" <option value=''>".$row['a']."</option>";

$current_price = $row['a'];

}

echo'    <option value="'.$row['b_id'].'">'.$row['b'].' ( '.$row['b_number'].')</option>';

}

echo"    </select>";

hi i have the above that prints a select box and inside it

comes out with

[b]A[/b]
apples
pairs
[b]B[/b]
bannas

but i want a space after every letter so;

[b]A[/b]
apples
pairs

[b]B[/b]
bannas

ne ideas please?
Link to comment
https://forums.phpfreaks.com/topic/26825-a-to-z-in-combo-box/
Share on other sites


One problem with using array indices what are one letter long, is that when the next person to look at your code has trouble understanding it.

Looking at the code, I dont see what is outputting which line. But, I would suggest putting

[code] echo "<option value=' '> </option>"; [/code]

Immediately prior to whichever line outputs the bold-type letter. Then, you eliminate the second line which adds the first (and now superfluous) blank line.
Link to comment
https://forums.phpfreaks.com/topic/26825-a-to-z-in-combo-box/#findComment-122687
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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