hi
i am trying to use an sql query which when you enter enter first or last name which excists in the table table, it should search the db and show the results id, first name, last name, and contratced_hoursmon_am fields from the record in database matching name entered on form and name field with a database record. however i am having huge problems executing this query, here is the code i am trying to use.
<?php // connects to database
require_once('Connections/mark.php');
error_reporting(E_ALL);
ini_set('display_errors', 'On');
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
$name=$_POST['name'];
// get variables
if(isset($_POST['ID'])){
$ID = $_POST['ID'];}
// Open an sql query
$sql = "SELECT* ID, FirstName, LastName, contracted_hoursmon_am, FROM staffmember tbl".;
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
// Loop through the results of the query
while($row=mysql_fetch_array($result)){
// Get the variable results
$ID = $conn->$row['ID'];
$FirstName = $conn->row['FirstName'];
$LastName = $conn->row['LastName'];
$contraced_hoursmon_am = $conn->row['contracted_hoursmon_am'];
while($row=mysql_fetch_assoc($result))
echo $FirstName=$row["FirstName"];
echo $LastName=$row["LastName"];
echo $ID=$row["ID"];
echo $contracted_hoursmon_am=$row["contracted_hoursmon_am"];
// print the variables fields retrieved from the record in database from the record with name enterd on form matching a name filed from a record in database
print_r($var);"$v'ID' <br>$v'FirstName' <br> $v'LastName' <br>$v'contracted_hoursmon_am' <br> ";
?>
<option value="<?=$ID?>" selected><?=($FirstName." ".$LastName)?></option>
<?php
}
// Closes the query
// Closes connection to database
?>
i am trying to use an sql query which when you enter enter first or last name which excists in the table table, it should search the db and show the results id, first name, last name, and contratced_hoursmon_am fields from the record in database matching name entered on form and name field with a database record. however i am having huge problems executing this query, here is the code i am trying to use.
<?php // connects to database
require_once('Connections/mark.php');
error_reporting(E_ALL);
ini_set('display_errors', 'On');
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
$name=$_POST['name'];
// get variables
if(isset($_POST['ID'])){
$ID = $_POST['ID'];}
// Open an sql query
$sql = "SELECT* ID, FirstName, LastName, contracted_hoursmon_am, FROM staffmember tbl".;
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
// Loop through the results of the query
while($row=mysql_fetch_array($result)){
// Get the variable results
$ID = $conn->$row['ID'];
$FirstName = $conn->row['FirstName'];
$LastName = $conn->row['LastName'];
$contraced_hoursmon_am = $conn->row['contracted_hoursmon_am'];
while($row=mysql_fetch_assoc($result))
echo $FirstName=$row["FirstName"];
echo $LastName=$row["LastName"];
echo $ID=$row["ID"];
echo $contracted_hoursmon_am=$row["contracted_hoursmon_am"];
// print the variables fields retrieved from the record in database from the record with name enterd on form matching a name filed from a record in database
print_r($var);"$v'ID' <br>$v'FirstName' <br> $v'LastName' <br>$v'contracted_hoursmon_am' <br> ";
?>
<option value="<?=$ID?>" selected><?=($FirstName." ".$LastName)?></option>
<?php
}
// Closes the query
// Closes connection to database
?>