I am new to this so please excuse the layout of the code on the page. What I have is a database with names of people in it, all the people are translators of some language or other.
I want to create the page so a user can click on a button to select all the translators that are available for a particular language, I have the database but am trying to build the page.
The code below works OK but starts with an error message because $sql is not set as I have commented it out, if I remove the comment from the line which reads $sql = "SELECT * WHERE language = 'English'" I don't get the error message but the buttons do not work to set the value of $sql.
I hope that explains things a bit better and I hope you can help.
Regards,
SDM
<html>
<head>
<title>Translators Data</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("translators",$db); ?>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<input type="submit" name='all' value="All">
<input type="submit" name='english' value="English">
<input type="submit" name='german' value="German">
<input type="submit" name='spanish' value="Spanish">
</form>
<?php
if($all)
{
$sql = "SELECT FROM people";
}
if($english)
{
$sql = "SELECT FROM people WHERE language = 'English'";
}
if($german)
{
$sql = "SELECT FROM people WHERE language = 'German'";
}
if($spanish)
{
$sql = "SELECT FROM people WHERE language = 'Spanish'";
}
//$sql = "SELECT * WHERE language = 'English'";
$result = mysql_query($sql,$db);
$num = mysql_num_rows($result);
$cur = 1;
echo "<p>Number of translators found: ".$num."</p>";
echo "<ol>";
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$id = $row["id"];
$name = $row["name"];
$address = $row["address"];
$phone = $row["phone"];
$email = $row["email"];
$language = $row["language"];
echo "<li><b>Translator Data:</b> <br><b>Name:</b> $name <br><b>Address:</b> $address <br><b>Phone Number:</b> $phone <br><b>Email:</b> <a href=\"mailto:$email\">$name</a> <br><b>Languages:</b> $language</li><br><br>";
$cur ++;
}
echo "</ol>";
?>
<br>
</body>
</html>