Вот код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Монитор параметров</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
<input type="checkbox" name="myrow[]" value="t" />Параметр T<br />
<input type="checkbox" name="myrow[]" value="p1" />Параметр P1<br />
<input type="checkbox" name="myrow[]" value="p2" />Параметр P2<br />
<input type="submit" value="Выбрать" name="submit"> </form>
<?php
function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}
if (IsChecked('myrow','t'))
{
mysql_connect("localhost", "root", "") or die("Ошибка подключения: " . mysql_error());
mysql_select_db("project"); $media_array = $_POST['myrow'];
$query = "SELECT t.id, t.t FROM t ";
$result = mysql_query($query);
echo '<table>';
while($myrow=mysql_fetch_assoc($result))
{
echo '<tr><td>'.$myrow['id'].'</td><td>'.$myrow['t'].'</td><td>'.$myrow['p1'].'</td><td>'.$myrow['p2'].'</td></tr>';
}
echo '</table>';
}
if (IsChecked('myrow','p1'))
{
mysql_connect("localhost", "root", "") or die("Ошибка подключения: " . mysql_error());
mysql_select_db("project"); $media_array = $_POST['myrow'];
$query = "SELECT t.id, p1.p1 FROM t INNER JOIN p1 WHERE t.id=p1.id";
$result = mysql_query($query);
echo '<table>';
while($myrow=mysql_fetch_assoc($result))
{
echo '<tr><td>'.$myrow['id'].'</td><td>'.$myrow['t'].'</td><td>'.$myrow['p1'].'</td><td>'.$myrow['p2'].'</td></tr>';
}
echo '</table>';
}
if (IsChecked('myrow','p2'))
{
mysql_connect("localhost", "root", "") or die("Ошибка подключения: " . mysql_error());
mysql_select_db("project"); $media_array = $_POST['myrow'];
$query = "SELECT t.id, p2,p2 FROM t INNER JOIN p2 WHERE t.id=p2.id";
$result = mysql_query($query);
echo '<table>';
while($myrow=mysql_fetch_assoc($result))
{
echo '<tr><td>'.$myrow['id'].'</td><td>'.$myrow['t'].'</td><td>'.$myrow['p1'].'</td><td>'.$myrow['p2'].'</td></tr>';
}
echo '</table>';
}
else
{
mysql_connect("localhost", "root", "") or die("Ошибка подключения: " . mysql_error());
mysql_select_db("project"); $media_array = $_POST['myrow'];
$query = "SELECT t.id, t.t, p1.p1, p2,p2 FROM t INNER JOIN p1 INNER JOIN p2 WHERE t.id=p1.id=p2.id";
$result = mysql_query($query);
echo '<table>';
while($myrow=mysql_fetch_assoc($result))
{
echo '<tr><td>'.$myrow['id'].'</td><td>'.$myrow['t'].'</td><td>'.$myrow['p1'].'</td><td>'.$myrow['p2'].'</td></tr>';
}
echo '</table>';
}
?>
</body> </html>
Заранее спасибо!