Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2004, 04:21 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

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
:::::::::::::::::::::::::::::::::
 
Old January 12th, 2004, 08:39 PM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thats very kind of you..
i'll try both of them...
but not use both one of them,only one of them..

 
Old January 13th, 2004, 03:50 AM
Authorized User
 
Join Date: Jan 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank u quesadilla5....
it works!!!!!!!
hahahahahahaha!!!!!!
really satisfy rite now!!!!
this is the best part of programming...
see what u want appear!!!
yahooo!!!

 
Old January 13th, 2004, 04:16 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Apek! So glad to hear you've got it working!
A pleasure to be of service!

: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
passing data and substr...HELP!!!!!!!!!!!! apek PHP How-To 1 January 11th, 2004 01:05 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.