HTML form Select Option display MySql database query
Posted: Thu Aug 17, 2006 6:00 pm
feyd | Please use
I created a html program(client.html)
how can i pass $result from server.php program to client.html? actually what is the best solution for this problem?
tx
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a database created in MySql, which has company information such as area code, address1, email and webaddress.
In the html form, when the user select the area code from the pull down menu without hiting any other button( Form/Select /Option ) , company information in that area should be displayed.
I wrote a php program (server.php)to read data from the databaseCode: Select all
<?php
$user="root";
$password="";
$database="bombay";
mysql_connect("kosala",$user,$password);
@mysql_select_db($database) or die("Unable to select database");
$item = $_REQUEST['item'];
echo "Option Selected : $item <br> ";
$query= "SELECT * FROM Bombayt0 ";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i<$num){
$CName=mysql_result($result,$i,"CName");
$CAdd=mysql_result($result,$i,"CAdd");
$CPCode=mysql_result($result,$i,"CPCode");
$CAdd=mysql_result($result,$i,"CAdd");
$CTel=mysql_result($result,$i,"CTel");
$CFax=mysql_result($result,$i,"CFax");
$CEmail=mysql_result($result,$i,"CEmail");
$CWeb=mysql_result($result,$i,"CWeb");
$i++;
}
?>Code: Select all
<html>
<head>
<script language="javascript" src="server.php">
</script>
</head>
<body>
<form name="form" >
<select method="post" name="item" onChange="go()">
<option value="1" > 1 </option>
<option value="2" > 2 </option>
</select>
<script type="text/javascript">
var selectedItem = 0;
function go(){
box=document.forms[0].item;
selectedItem = document.forms[0].item.options[box.selectedIndex].value;
}
</script>
Company Name: <input type="text" name="CName" > <br>
Company Addr: <input type="text" name="CAdd" ><br>
Phone: <input type="text" name="CTel" ><br>
Fax: <input type="text" name="fax" ><br>
E-mail: <input type="text" name="CEmail" ><br>
Web: <input type="text" name="CWeb" ><br>
</form>
</body>
</html>how can i pass $result from server.php program to client.html? actually what is the best solution for this problem?
tx
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]