Hi All,
Use this code
Here the function showoptions takes table name as first argument, id as second argument and value to be displayed in the screen as third argument.
------------------------------------------------------------------------------------------------------
Showdata.php
<html>
<body>
<?php
include('dbconnect.php');
?>
<form action=# method=post>
<pre>
Project Name <input>
Project Members <select name=projmembers multiple> <?php showoptions("reg_st","id","name"); ?></select>
</pre>
</form>
</body>
</html>
-------------------------------------------------------------------------------------
dbconnect.php
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("snitdb",$con);
function showoptions($table,$value,$display)
{
$qr="select * from $table ";
echo $qr;
$data=mysql_query($qr);
while($row=mysql_fetch_array($data))
{
echo "<option value='".$row[$value]."'>".$row[$display]."</option>";
}
}
?>
Use this code
Here the function showoptions takes table name as first argument, id as second argument and value to be displayed in the screen as third argument.
------------------------------------------------------------------------------------------------------
Showdata.php
<html>
<body>
<?php
include('dbconnect.php');
?>
<form action=# method=post>
<pre>
Project Name <input>
Project Members <select name=projmembers multiple> <?php showoptions("reg_st","id","name"); ?></select>
</pre>
</form>
</body>
</html>
-------------------------------------------------------------------------------------
dbconnect.php
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("snitdb",$con);
function showoptions($table,$value,$display)
{
$qr="select * from $table ";
echo $qr;
$data=mysql_query($qr);
while($row=mysql_fetch_array($data))
{
echo "<option value='".$row[$value]."'>".$row[$display]."</option>";
}
}
?>
No comments:
Post a Comment