evry2004
asked on
PHP-MYSQL-HTML
Hi all.
I want to build a simple html form with the followings:
- Select Product :(look up field. get data from database product table)
- Expire Date:
- Delivery Date:
- Select Supplier:(look up field. get data from database supplier table)
- Quantity:
- Select State:(between Stock-In or Stock-Out)
but, viewed in a browser, it looks a bit messy.
can someone help please?
I want to build a simple html form with the followings:
- Select Product :(look up field. get data from database product table)
- Expire Date:
- Delivery Date:
- Select Supplier:(look up field. get data from database supplier table)
- Quantity:
- Select State:(between Stock-In or Stock-Out)
but, viewed in a browser, it looks a bit messy.
can someone help please?
Are you able to post the code you have at the moment?
ASKER
sorry forgot it.
here they are:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Delicious Ltd | Product Registration</title>
<link href="delicious/titre.css" rel="stylesheet" type="text/css" />
<link href="delicious/label.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$useriddb = "root";
$passworddb = "";
// Connecting to and selecting a database
$connect = mysql_connect('localhost', $useriddb, $passworddb)
or die('Could not connect: ' . mysql_error());
//echo '<b>Step 1:</b> Connected successfully! <BR>';
$db = 'db_delicious'; // My database is called test
mysql_select_db($db) or die('Could not select database ('.$db.') because of : '.mysql_error());
//echo '<b>Step 2:</b> Connected to ('.$db.') successful!<BR>';
// create a look up field for product name
$sql1=" SELECT item_id, name from product";
$sql2=" SELECT supplier_name from supplier";
echo"<form method=post action=\"\" >";
?>
<center>
<table width="500" border="1" cellpadding="0" cellspacing="0" >
<tr>
<td align="center"><table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" rowspan="3"><img src="images/login.jpg" alt="image" width="149" height="399" /></td>
<td width="300"><img src="images/delicious.jpg" alt="image" width="299
" height="113" /></td>
</tr>
<tr>
<td width="300" height="49"><h3 align="center" class="titre"> Stock Registration </h3></td>
</tr>
<tr>
<td width="300" align="left" valign="top">
<form name="product" method="post" action="delicious/producti onn.php">
<table width="300" border="">
<tr>
<td>Select Product:</td>
<td>
<?php
echo" <select name=\"name\" >";
$result1=mysql_query($sql1 , $connect);
while($row=mysql_fetch_arr ay($result 1)){
$item_id=$row["item_id"];
$name=$row["name"];
echo"<option value=\"$item_id\">$name";
}
echo"<\select>";
?>
</td>
</tr>
<tr>
<td>Expire Date:</td>
<td><?php echo" <input name=\"exp_date\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Delivery Date:</td>
<td><?php echo" <input name=\"del_date\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Select Supplier:</td>
<td>
<?php
// create supplier look-up field
echo" <select name=\"supplier_name\" >";
$result2=mysql_query($sql2 , $connect);
while($row=mysql_fetch_arr ay($result 2)){
$supplier_name=$row["suppl ier_name"] ;
echo"<option >$supplier_name";
}
echo"<\select>";
?>
</td>
</tr>
<tr>
<td>Quantity:</td>
<td><?php echo" <input name=\"quantity\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Select State:</td>
<td>
<?php
// create state look-up field
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In";
echo"<option >Stock-Out";
?>
</td>
</tr>
<tr>
<td><input name="submit" type="submit" value="SUBMIT" /></td>
<td><input name="reset" type="reset" value="RESET" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
</table>
</center>
</body>
</html>
here they are:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Delicious Ltd | Product Registration</title>
<link href="delicious/titre.css"
<link href="delicious/label.css"
</head>
<body>
<?php
$useriddb = "root";
$passworddb = "";
// Connecting to and selecting a database
$connect = mysql_connect('localhost',
or die('Could not connect: ' . mysql_error());
//echo '<b>Step 1:</b> Connected successfully! <BR>';
$db = 'db_delicious'; // My database is called test
mysql_select_db($db) or die('Could not select database ('.$db.') because of : '.mysql_error());
//echo '<b>Step 2:</b> Connected to ('.$db.') successful!<BR>';
// create a look up field for product name
$sql1=" SELECT item_id, name from product";
$sql2=" SELECT supplier_name from supplier";
echo"<form method=post action=\"\" >";
?>
<center>
<table width="500" border="1" cellpadding="0" cellspacing="0" >
<tr>
<td align="center"><table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" rowspan="3"><img src="images/login.jpg" alt="image" width="149" height="399" /></td>
<td width="300"><img src="images/delicious.jpg"
" height="113" /></td>
</tr>
<tr>
<td width="300" height="49"><h3 align="center" class="titre"> Stock Registration </h3></td>
</tr>
<tr>
<td width="300" align="left" valign="top">
<form name="product" method="post" action="delicious/producti
<table width="300" border="">
<tr>
<td>Select Product:</td>
<td>
<?php
echo" <select name=\"name\" >";
$result1=mysql_query($sql1
while($row=mysql_fetch_arr
$item_id=$row["item_id"];
$name=$row["name"];
echo"<option value=\"$item_id\">$name";
}
echo"<\select>";
?>
</td>
</tr>
<tr>
<td>Expire Date:</td>
<td><?php echo" <input name=\"exp_date\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Delivery Date:</td>
<td><?php echo" <input name=\"del_date\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Select Supplier:</td>
<td>
<?php
// create supplier look-up field
echo" <select name=\"supplier_name\" >";
$result2=mysql_query($sql2
while($row=mysql_fetch_arr
$supplier_name=$row["suppl
echo"<option >$supplier_name";
}
echo"<\select>";
?>
</td>
</tr>
<tr>
<td>Quantity:</td>
<td><?php echo" <input name=\"quantity\" type=\"text\" /> "; ?></td>
</tr>
<tr>
<td>Select State:</td>
<td>
<?php
// create state look-up field
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In";
echo"<option >Stock-Out";
?>
</td>
</tr>
<tr>
<td><input name="submit" type="submit" value="SUBMIT" /></td>
<td><input name="reset" type="reset" value="RESET" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
</table>
</center>
</body>
</html>
So what exactly do you want to change? Which bit looks messy?
ASKER
from the input "select Supplier" til the end,
it doesnt display correctly in the browser as if I had forgotten to put "<br>" somewhere.
Also I have the "</select>" appearing in both my look up fields.
just try to display in browser and you see the display.
thanks
it doesnt display correctly in the browser as if I had forgotten to put "<br>" somewhere.
Also I have the "</select>" appearing in both my look up fields.
just try to display in browser and you see the display.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the look up fields were sorted, but this part is still messy.
the tag need sorting.
here is the part:
<tr>
<td>Select State:</td>
<td>
<?php
// create state look-up field
echo" <select name=\"state\" >";
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In</option>";
echo"<option >Stock-Out</option>";
echo"<\select>";
?>
</td>
</tr>
the tag need sorting.
here is the part:
<tr>
<td>Select State:</td>
<td>
<?php
// create state look-up field
echo" <select name=\"state\" >";
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In</option>";
echo"<option >Stock-Out</option>";
echo"<\select>";
?>
</td>
</tr>
ASKER
<tr>
<td>Select State:</td>
In the following tag
<td>
<?php
// create state look-up field
echo" <select name=\"state\" >";
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In</option>";
echo"<option >Stock-Out</option>";
echo"<\select>";
?>
</td>
</tr>
I got ride of the following code:
echo"<input type=\"text\" name=\"state\">" ;
and its all fine. thanks a lot for your contribution as I was too tired to spot that.
<td>Select State:</td>
In the following tag
<td>
<?php
// create state look-up field
echo" <select name=\"state\" >";
echo"<input type=\"text\" name=\"state\">" ;
echo"<option >Stock-In</option>";
echo"<option >Stock-Out</option>";
echo"<\select>";
?>
</td>
</tr>
I got ride of the following code:
echo"<input type=\"text\" name=\"state\">" ;
and its all fine. thanks a lot for your contribution as I was too tired to spot that.
Glad to be of assistance :)