Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 09-07-2005, 06:19 AM   #1 (permalink)
mamuni
Registered User
 
Join Date: Sep 2005
Posts: 1
mamuni is on a distinguished road
Drop down form + mysql please... could you help me?

Hello all. Excuse me if the query is so basic. I am writing a script that allows me to take data from a table myql to a lists drop down form to allow to select a product finally and to show its characteristics (not images) and a Link that will be made up of a fixed URL + a code of product (Web Part naumber) to enter to its corresponding webpage. May be, somebody can help me to follow this? Many7 thanks in advance!!!

Im transcribing the code:

PHP Code:
<?PHP 
$Host 
""
$User ""
$Passwd ""
$DBName ""
$TableName ""

$Link mysql_connect($Host$User$Passwd) or die("Could not connect: " mysql_error()); 

$Link mysql_connect($Host$User$Passwd) or die("Could not connect: " mysql_error()); 

$Query "SELECT Distinct manufacturer "
"FROM $TableName"
$Result mysql_db_query$DBName$Query$Link ); 
?> 
<HTML> 
 <HEAD> 
  <SCRIPT language="JavaScript"> 
   <!-- 
    function BodyLoad() { 
        var select = document.FormName.manufacturer; 
        select.options[0] = new Option("Choose One"); 
        select.options[0].value = 0; 
        <?PHP 
        $ctr 
1
        While( 
$Row mysql_fetch_array($Result) ) { 
            echo 
"select.options[" $ctr "] = new Option(\"" $Row["manufacturer"] . "\");\n"
            echo 
"select.options[" $ctr "].value = \"" $Row['model'] . "\";\n"
            
$ctr++; 
        } 
        
?> 
    } 

    function Fill_Sub() { 
        var main_select = document.FormName.manufacturer; 
        var sub_select = document.FormName.model; 
        if( main_select.options[main_select.selectedIndex].value != 0 ) { 
            sub_select.length = 0; 
        } 
        <?PHP 
        $Query 
"SELECT Distinct manufacturer ""FROM $TableName"
        
$Result mysql_db_query$DBName$Query$Link ); 

        while( 
$Row mysql_fetch_array($Result) ) { 
            
?> 
            if( main_select.options[main_select.selectedIndex].text == "<?PHP echo $Row[manufacturer]; ?>" ) { 
                <?PHP 
                $Query2 
"SELECT model ""FROM $TableName ""WHERE manufacturer = '$Row[manufacturer]'"
                
$Result2 mysql_db_query$DBName$Query2$Link ); 

                
$ctr 0
                While( 
$Row2 mysql_fetch_array($Result2) ) { 
                    echo 
"sub_select.options[" $ctr "] = new Option(\"" $Row2["model"] . "\");\n"
                    echo 
"sub_select.options[" $ctr "].value = \"" $Row['model'] . "\";\n"
                    
$ctr++; 
                } 
                
?> 
            } 

            <?PHP 
        


        
mysql_close($Link); 
        
?> 
    } 
    --> 
  </SCRIPT> 
 </HEAD> 
 <BODY onload="BodyLoad();"> 
 <FORM name="FormName" method="POST" action=""> 
  <TABLE border="1"> 
   <TR> 
    <TD>Manufacturer</TD> 
    <TD>Model</TD> 
   </TR> 
   <TR> 
    <TD> 
     <SELECT name="manufacturer" onchange="Fill_Sub();"></SELECT> 
    </TD> 
    <TD> 
     <SELECT name="model" onchange="submit();"></SELECT> 
    </TD> 
   </TR> 
  </TABLE> 
 </FORM> 
 </BODY> 
</HTML>
----------------------------------------------------

Table:

manufacturer model prefix webpartnumber Suffix Lamp Type Wattage Lamp hours Display Trade Canx
Juan X 15e 1 X 15e Lamp UHP 250 watt, 2000 hour, projector 286,50 y
Pedro X 15i 2 X 15i Lamp UHP 250 watt, 2000 hour, projector 286,50 y
Pedro X 30e 8 X 30e Lamp UHP 250 watt, 2000 hour, projector 286,50
Tito X 30i 7 X 30i Lamp UHP 250 watt, 2000 hour, projector 286,50
Roberto SX 15e 7 SX 15e Lamp UHP 250 watt, 2000 hour, projector 286,50 y

-----------------------------------------------

Mamu

Last edited by redhead; 09-07-2005 at 08:01 AM. Reason: Fixing indentation to give some form of idear where which part fits in.
mamuni is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert HTML form data into mysql database ? plomon PHP 5 02-06-2005 08:23 AM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 5 07-07-2002 09:54 AM


All times are GMT -8. The time now is 01:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting