I have the following code below. When a user logs in, they are presented with a form with a series of select boxes generated from a database.
What I want to be able to do is when the user clicks a button a new identical table row is generated. Or is it possible the user can select how many table rows he/she needs.
Is this possible to do without having to rewrite the script Ive already battled with.
<?php
echo "
<html><head><title>Aventis</title></head>
<body>";
require "./config.inc.php";
$db_connect = mysql_connect ($host,$user,$passwd);
mysql_select_db($database, $db_connect);
$failure=0;
if ( $rep_name )
{
switch ($page) {
case "login":
$result=mysql_query("select * from rep where rep_name='$rep_name'",$db_connect) or die ("cant do it");
while ($row=mysql_fetch_array($result)) {
if ($row["rep_passwd"] != $rep_passwd) { $failure = 1; break; }
$name = $row['rep_name'];
$area = $row['area'];
echo "
<table border='1' cellpadding='3' cellspacing='0' width='100%'>
<tr>
<td>Rep: $name</td><td>Area: $area</td>
</tr>
</table><br>";
$sql = "SELECT * from physicians";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
echo"<table width='100%' border='1' cellpadding='3' cellspacing='0'>
<tr><th>Rep.</th><th>Dr. Name</th><th>Speciality</th></tr>
<tr><td>1</td><td>";
if ($count > 0) {
echo "<select name='physisian'>";
while ($row = mysql_fetch_array($result))
{
echo "<option> " . $row['f_name'] . " " . $row['l_name'] . ", Code: " . $row['dr_code'] . "</option>";
}
echo "</select>";
}
echo "
</td><td>";
$sql = "SELECT * from speciality";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
echo "<select name='speciality'>";
while ($row = mysql_fetch_array($result))
{
echo "<option>" . $row['speciality'] . "</option>";
}
echo "</select>";
echo "
</td>
</tr>
</table>";
}
//default:
//echo "Wrong username";
//break;
}
}
else if ($failure == 1)
{ echo "Wrong details"; }
else { echo"
<form method='post' action='$PHP_SELF?page=login'>
Username: <input type='text' name='rep_name'><br>
Password: <input type='password' name='rep_passwd'><br>
<input type='submit' value='Submit'>
";
}
echo "
</body>
</html>";
?>