Guest_imported
New member
- Jan 1, 1970
- 0
Hello all,
I am new to PHP & MYSQL, so may I please have some help?
I am using a HTML submit button to enter 2 variables into php. I can get it working with one variable but when I try to use the 2 it appears that it doesn't like to accept the second to do the SQL query. I have a feeling that it is my syntax but I havn't nailed the problem yet.The code is as follows....
<html>
<body>
<?php
$db = mysql_connect("localhost", "root"
mysql_select_db("mydb",$db); //selects database
// This prints the last name depending on the address you type in. "last"
// and "address" are columns in the MYSQL database.
if ($submit)
{
$result = mysql_query("SELECT * FROM employees WHERE $column like '%$bit%'",$db);
$myrow = mysql_fetch_array($result);
printf($myrow["last"]);
}
?>
</ This is the search button />
<form method="post" action="<?php echo $PHP_SELF?>">
Search by - <input type="Text" name="column" value="<?php echo $column ?>">
for <input type="Text" name "bit" value="<?php echo $bit ?>">
<input type="submit" name="submit" value="Enter information">
</form>
</body>
</html>
regards,
Dion
I am new to PHP & MYSQL, so may I please have some help?
I am using a HTML submit button to enter 2 variables into php. I can get it working with one variable but when I try to use the 2 it appears that it doesn't like to accept the second to do the SQL query. I have a feeling that it is my syntax but I havn't nailed the problem yet.The code is as follows....
<html>
<body>
<?php
$db = mysql_connect("localhost", "root"
mysql_select_db("mydb",$db); //selects database
// This prints the last name depending on the address you type in. "last"
// and "address" are columns in the MYSQL database.
if ($submit)
{
$result = mysql_query("SELECT * FROM employees WHERE $column like '%$bit%'",$db);
$myrow = mysql_fetch_array($result);
printf($myrow["last"]);
}
?>
</ This is the search button />
<form method="post" action="<?php echo $PHP_SELF?>">
Search by - <input type="Text" name="column" value="<?php echo $column ?>">
for <input type="Text" name "bit" value="<?php echo $bit ?>">
<input type="submit" name="submit" value="Enter information">
</form>
</body>
</html>
regards,
Dion