Quote:
quote:
what does he mean??and how to fix the updating the value of $depan inside the cycle he not reply until now...
|
Well he means that you are using the last value of $depan, during iteration in the while loop, you overwrite the value of $depan with each pass. So if "W" is the last value, then that's why $_POST["front"] contains "W".
Try this:
Code:
<select name="front" size="1" >
<?php
$mesin = mysql_query("SELECT * FROM ".$DBprefix."tPartMinor group by idMajor order by idMajor");
if (empty($mesin))
{
echo mysql_error().": ";
echo mysql_errno()."<br />\n";
}
$default_value = "Hi I\'m selected by default!";
while ($dbq = mysql_fetch_array($mesin))
{
// Quote your string indices!
$depan = substr($dbq["idMajor"],0,1);
$option = "<option value='{$depan}'";
if ($default_value == $dbq["idMajor"])
{
$option .= " selected='selected'";
}
$option .= ">{$dbq["idMajor"]}</option>";
echo $option;
}
?>
</select>
Since you are passing "noTag" to another script anyway, why not make it itself the $_POST["front"] field. If you do need the value present in the $_POST["noTag"]; then do the substring operation in the next script on the $_POST["noTag"]; variable instead of in the first script while you are building the noTag set of options.
That would be done like so:
Code:
$query2 = "SELECT * FROM ".$DBprefix." tPartMinor WHERE idMinor LIKE '".substr($_POST["noTag"], 0, 1)."%'";
$mesin = mysql_query($query2);
while ($dbq = mysql_fetch_array($mesin))
{
echo "<option value='{$dbq["idMinor"]}'>{$dbq["idMinor"]}</option>\n";
}
Do one or the other but not both.
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::