help with layout display in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LinDaOopD
    New Member
    • Feb 2007
    • 4

    help with layout display in php

    hi to all.. I'm Linda,20 . i'm a trainee and my platform is PHP.
    i've joined this community hoping to find good friends and ppl who will help me out.
    i dont know about u guys but i find php boring, dont u think.
    any ways please help me out i cant seem to get a better layout display for my form. I want to have a drop down list and a combo box in the same row but i dont want the cell widht of the drop down to be wide because of the combo box. how can i get it right??
  • mainul
    New Member
    • Sep 2006
    • 51

    #2
    Hi Linda,
    Dropdown and Combo box is same. what you exactly want let us know and what code u so far wrote please post that.

    best regards
    Mainul

    Comment

    • LinDaOopD
      New Member
      • Feb 2007
      • 4

      #3
      well its like... one i'll keep as a drop down and the other will be a multiple select. with size of 8.
      so i would want more than one value that i select from another list into this box.
      so far i cant seem to get the display right. because of the size of the combobox. the width of the row is disturbed

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by LinDaOopD
        well its like... one i'll keep as a drop down and the other will be a multiple select. with size of 8.
        so i would want more than one value that i select from another list into this box.
        so far i cant seem to get the display right. because of the size of the combobox. the width of the row is disturbed
        Sound more like a Javascript issue than a PHP issue to me.

        Comment

        • LinDaOopD
          New Member
          • Feb 2007
          • 4

          #5
          Originally posted by r035198x
          Sound more like a Javascript issue than a PHP issue to me.

          well actually i'm well aware of the fact but i have to use php . and even the display will be in HTML tags too. i just dont seem to get any lead

          Comment

          • mainul
            New Member
            • Sep 2006
            • 51

            #6
            [PHP]
            <?php


            $dbservertype=' mysql';
            $servername=''; // database server name ex: localhost
            // username and password to log onto db server
            $dbusername=''; //use your database user name here ex: root
            $dbpassword=''; //put db password here
            // name of database
            $dbname='tutori al';

            ////////////////////////////////////////
            ////// DONOT EDIT BELOW /////////
            ///////////////////////////////////////
            connecttodb($se rvername,$dbnam e,$dbusername,$ dbpassword);
            function connecttodb($se rvername,$dbnam e,$dbuser,$dbpa ssword)
            {
            global $link;
            $link=mysql_con nect ("$servername", "$dbuser","$dbp assword");
            if(!$link){die( "Could not connect to MySQL");}
            mysql_select_db ("$dbname",$lin k) or die ("could not open db".mysql_error ());
            }
            //////// End of connecting to database ////////
            ?>

            <!doctype html public "-//w3c//dtd html 3.2//en">

            <html>

            <head>
            <title>Multip le drop down list box from plus2net</title>
            <meta name="GENERATOR " content="Arachn ophilia 4.0">
            <meta name="FORMATTER " content="Arachn ophilia 4.0">
            <SCRIPT language=JavaSc ript>
            function reload(form)
            {
            var val=form.cat.op tions[form.cat.option s.selectedIndex].value;
            self.location=' dd.php?cat=' + val ;
            }

            </script>
            </head>

            <body>
            <?

            @$cat=$_GET['cat']; // Use this line or below line if register_global is off
            //@$cat=$HTTP_GET _VARS['cat']; // Use this line or above line if register_global is off

            ///////// Getting the data from Mysql table for first list box//////////
            $quer2=mysql_qu ery("SELECT DISTINCT category,cat_id FROM category order by category");
            ///////////// End of query for first list box////////////

            /////// for second drop down list we will check if category is selected else we will display all the subcategory/////
            if(isset($cat) and strlen($cat) > 0){
            $quer=mysql_que ry("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
            }else{$quer=mys ql_query("SELEC T DISTINCT subcategory FROM subcategory order by subcategory"); }
            ////////// end of query for second subcategory drop down list box ///////////////////////////

            echo "<form method=post name=f1 action='dd-check.php'>";
            /// Add your form processing page address to action in above line. Example action=dd-check.php////
            ////////// Starting of first drop downlist /////////
            echo "<select name='cat' onchange=\"relo ad(this.form)\" ><option value=''>Select one</option>";
            while($noticia2 = mysql_fetch_arr ay($quer2)) {
            if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia 2[cat_id]'>$noticia2[category]</option>"."<BR>" ;}
            else{echo "<option value='$noticia 2[cat_id]'>$noticia2[category]</option>";}
            }
            echo "</select>";
            ////////////////// This will end the first drop down list ///////////

            ////////// Starting of second drop downlist /////////
            echo "<select name='subcat'>< option value=''>Select one</option>";
            while($noticia = mysql_fetch_arr ay($quer)) {
            echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
            }
            echo "</select>";
            ////////////////// This will end the second drop down list ///////////
            //// Add your other form fields as needed here/////
            echo "<input type=submit value=Submit>";
            echo "</form>";
            ?>

            </body>

            </html>

            [/PHP]


            use the database below. just run the copy paste it and run the SQL. Give the database name as 'tutorial'


            CREATE TABLE category ( cat_id int(2) NOT NULL auto_increment, category varchar(25) NOT NULL default '', PRIMARY KEY (cat_id) ) TYPE=MyISAM;
            # # Dumping data for table `category` #
            INSERT INTO category VALUES (1, 'Fruits'); INSERT INTO category VALUES (2, 'Colors'); INSERT INTO category VALUES (3, 'Games'); INSERT INTO category VALUES (4, 'Vehicles');
            # -------------------------------------------------------- # # Table structure for table `subcategory` #
            CREATE TABLE subcategory ( cat_id int(2) NOT NULL default '0', subcategory varchar(25) NOT NULL default '' ) TYPE=MyISAM;
            # # Dumping data for table `subcategory` #
            INSERT INTO subcategory VALUES (1, 'Mango'); INSERT INTO subcategory VALUES (1, 'Banana'); INSERT INTO subcategory VALUES (1, 'Orange'); INSERT INTO subcategory VALUES (1, 'Apple'); INSERT INTO subcategory VALUES (2, 'Red'); INSERT INTO subcategory VALUES (2, 'Blue'); INSERT INTO subcategory VALUES (2, 'Green'); INSERT INTO subcategory VALUES (2, 'Yellow'); INSERT INTO subcategory VALUES (3, 'Cricket'); INSERT INTO subcategory VALUES (3, 'Football'); INSERT INTO subcategory VALUES (3, 'Baseball'); INSERT INTO subcategory VALUES (3, 'Tennis'); INSERT INTO subcategory VALUES (4, 'Cars'); INSERT INTO subcategory VALUES (4, 'Trucks'); INSERT INTO subcategory VALUES (4, 'Blkes'); INSERT INTO subcategory VALUES (4, 'Train');




            let me know whether it fulfills your requirements.

            Best regards
            Mainul

            Comment

            Working...