I am trying to build a script in PHP, the script needs to select a id
from the database. If the selected id = 1 the scripts needs to show the text "One"
Here is what I have:
<?php
$user_name = "root";
$password = "";
$database = "db";
$server = "localhost";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$result =mysql_query("SELECT id FROM users WHERE user_id=1");
if ($result=1)
{
echo 'One';
}
if ($result=2)
{
echo 'Two';
}
if ($result=3)
{
echo 'Three';
}
else
{
echo 'None';
}
}
else {
print "Database NOT Found.";
mysql_close($db_handle);
}
?>
After running this script I get: OneTwoThree in my screen.
What am I doing wrong? How can I write this script so it will give me the right text?