Hi all, I cant get this at all.
Ihave a form with a series of radio button, all which represent a category of animal. I have given each radio button a value which is the same as the mysql table it represents.
For example:
<input type="radio" name="delete" value="tortoises">Tortoises<br />
When this radio button is checked, the contents of the table named 'tortoises' should be displayed.
I dont want to have to write code for each category if possible.
Here is my form with all the radio buttons.
removestock.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stocklist update</title>
<link href="../css/gallery_submit.css" rel="stylesheet" type="text/css" />
<link href="../css/removestock.css" rel="stylesheet" type="text/css" />
<link href="../css/template.css" rel="stylesheet" type="text/css" />
<body>
<div class="span4">
<p>Remove Livestock</p>
</div>
<form class="form" action="remove.php" method="post" enctype="multipart/form-data" name="stockupdate_form" id="stockupdate_form" style="margin-bottom:0px;">
<h1 style="margin-bottom: 0px">Chose a category, only one can be chosen at a time:</h1>
<label><span class="span2">Amphibians</span></label><br />
<label><b>Snakes</b></label><br />
<input type="radio" name="delete" value="boids">Boids<br />
<input type="radio" name="delete" value="colubrids">Colubrids<br />
<input type="radio" name="delete" value="other_snakes">Other<br />
<label><b>Lizards</b></label><br />
<input type="radio" name="delete" value="monitors">Monitors/Tegus<br />
<input type="radio" name="delete" val ue="agmids">Agmids<br />
<input type="radio" name="delete" value="geckos">Geckos<br />
<input type="radio" name="delete" value="other_lizards">Other<br />
<label><b>Chelonia</b></label><br />
<input type="radio" name="delete" value="tortoises">Tortoises<br />
<input type="radio" name="delete" value="turtles">Turtles<br />
<label><b>Amphibians</b></label><br />
<input type="radio" name="delete" value="frogs">Frogs/Toads<br />
<input type="radio" name="delete" value="other_amphibs">Other<br />
<label><b>Inverts</b></label><br />
<input type="radio" name="delete" value="arachnids">Arachnids<br />
<input type="radio" name="delete" value="other_inverts">Other<br />
<input type="submit" name="next" value="Next" />
<input name="submitted_form" type="hidden" id="submitted_form" value="stockupdate_form" />
</form>
</body>
</html>
This is the file that lists the contents of the table.
remove.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stocklist update</title>
<link href="../css/gallery_submit.css" rel="stylesheet" type="text/css" />
<link href="../css/template.css" rel="stylesheet" type="text/css" />
<body>
<div class="span4">
<p>Remove Livestock</p>
</div>
<?php
include 'connect.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['next']))
{
$selected_radio = $_POST['delete'];
?>
<form class='form' action='remove2.php' method='post' enctype='multipart/form-data' name='stockupdate_form' id='stockupdate_form' style='margin-bottom:0px;'>;
<?php
if ($selected_radio == 'boids')
{
$data = mysql_query("SELECT * FROM boids ORDER BY id DESC")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo "<span class='span2'>";
echo $info['species'];
echo ' : ';
echo $info['year'];
echo ' : ';
echo $info['sex'];
echo ' : ';
echo '£';
echo $info['price'];
echo "<input type='checkbox' name='check[{$info['id']}]' />";
echo '<br />';
echo "</span>";
}
}
}
}
?>
<input type='submit' name='remove' value='Remove' />
</form>
</body>
</html>
As you can see doing it this way will result in A LOT of code by the time I would do it for each category!
Can anyone help?
Thanks for looking.....................