By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

help with layout display in php

P: 4
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??
Feb 27 '07 #1
Share this Question
Share on Google+
5 Replies


P: 51
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
Feb 27 '07 #2

P: 4
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
Feb 27 '07 #3

10K+
P: 13,264
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.
Feb 27 '07 #4

P: 4
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
Feb 27 '07 #5

P: 51
[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='tutorial';

////////////////////////////////////////
////// DONOT EDIT BELOW /////////
///////////////////////////////////////
connecttodb($servername,$dbname,$dbusername,$dbpas sword);
function connecttodb($servername,$dbname,$dbuser,$dbpasswor d)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) 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>Multiple drop down list box from plus2net</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.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_query("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_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
}else{$quer=mysql_query("SELECT 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=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}
else{echo "<option value='$noticia2[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_array($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
Feb 27 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.