Hi
I got 1 static drop down list, 1 dynamic drop down list(shows content of a mysql table) and content of another mysql table on the same webpage. They are all placed on 3 different forms.
The selected option in the first list triggers the 2nd list on the page. However, this works fine.
My problem is that i cannot get the data from the 2nd table displayed once the user has selected a value from the 2nd drop down list.
I know I could try and display the last table on a different page but it all has to be on the same page.
Here's some code:
//first form
<form name="reporttype" method="post" action="report.php?act=submit">
<label>
<span class="style16">View report by </span>
<select name="parameters" id="parameters" class="style16" >
<option>Client </option>
<option>Supplier</option>
<option>URL</option>
</select>
</label>
<p>
<label>
<input name="submit" type="submit" id="submit" value="Submit" >
</label>
</p>
</form>
//2nd form
<form action="report.php?act=view" method="post" name="textform" class="style16">
<?php
require_once("functions.php");
$connection = db_connect();
$suppliers=mysql_query("select * from supplier order by company");
$clients=mysql_query("select * from client order by company");
$n=mysql_numrows($suppliers);
$m=mysql_numrows($clients);
//$action = $_GET['act'];
if ($_POST['submit'])
{
$option = $_POST['parameters'];
switch ($option)
{
//default: header("location:report.php"); break;
case "Client":
$label= "Client Company: ";
echo $label;
echo "<select name=\"parameter\" id=\"parameter\"><br />";
$i=0;
while ($i<$m)
{ $row = mysql_fetch_array($clients);
echo "<option value=\"".$row['company']."\">".$row['company']."\n ";
$i++;
}
echo " </select>";
echo "<br /><br />";
echo"<input name=\"view\" type=\"submit\" id=\"view\" value=\"View Reports\">";
echo"<input type=\"hidden\" name=\"label\" value=\"".$label."\">";
break;
case "Supplier":
$label="Supplier Company: ";
echo $label;
echo "<select name=\"parameter\" id=\"parameter\"><br />";
$i=0;
while ($i<$n)
{ $row = mysql_fetch_array($suppliers);
echo "<option value=\"".$row['company']."\">".$row['company']."\n ";
$i++;
}
echo " </select>";
echo "<br /><br />";
echo"<input name=\"view\" type=\"submit\" id=\"view\" value=\"View Reports\">";
echo"<input type=\"hidden\" name=\"label\" value=\"".$label."\">";
break;
case "URL":
$label="URL: ";
echo $label;
echo "<select name=\"parameter\" id=\"parameter\"><br />";
$i=0;
while ($i<$m)
{ $row = mysql_fetch_array($clients);
echo "<option value=\"".$row['url']."\">".$row['url']."\n ";
$i++;
}
echo " </select>";
echo "<br /><br />";
echo"<input name=\"view\" type=\"submit\" id=\"view\" value=\"View Reports\">";
echo"<input type=\"hidden\" name=\"label\" value=\"".$label."\">";
break;
}
}
?></p>
</form>
//3rd form
<?php
$action = $_GET['act'];
if ($action == viewrep)
// if (($_POST['parameter'])&&($_POST['view']))
{
$parameter= $_POST['parameter'];
echo $parameter;
$label=$_POST['label'];
switch ($label)
{
case "Client Company: ":
$query=mysql_query("select * from report where companyname='$parameter' and reporttype='client' order by id desc");
$n=mysql_numrows($query);
echo "<table>";
$i=0;
while ($i<$n)
{ $row = mysql_fetch_array($query);
$r=$row['companyname'];
echo"<tr>";
echo"<td>";
echo"<a href='reportclient.php\?name=$r'>$r</a\>";
echo"</td>";
echo"</tr>";
}
echo"</table>";
echo"<input name=\"viewrep\" type=\"submit\" id=\"viewrep\" value=\"View Report\">";
}
}
ob_end_flush();
?>
</span>
</form>