this is going to be my second post, I am very confused and need some assistance. first I will explain what I would want it to do and then post my code. I am first search a database using first name, last name, or a date to print the results. I first need help in only printing a repeating name once. It is printing every possible case and I would like it to match the fields (except arrival, reason, or even company (these can change ) ) Next once the results print on my search page, I would like radio buttons to be next to each set of data. for instance, if there are two people with the last name brown, i would like the first name, last name, and DL# to have ONE radio button next to it. resulting in two total buttons. this is where i am having trouble. once the selected radio is pressed and the next button (hyperlink) is pressed, i will then direct the user to a set of forms where the selected data ( firstname, lastname, dl#, company) is pre filled in the spots.
so all in all i need help limiting the prints of repeating individuals, and also i need assistance with saving data after a search function using a radio button to then print and pre populate the forms on the following page. my code currently for the search function is:
<h3>Search By First Name, Last Name, or Arrival Date (20XX-MO-DY)</h3>
<form action="searchpage.php" method="GET">
<label>Search:
<input type="text" name="searchname" id="searchname" />
</label>
<input type="submit" value="Search" />
</form>
My searchpage is :
<?php
$host = "localhost"; //server
$db = "practice_table"; //database name
$user = "root"; //databases user name
$pwd = ""; //password
mysql_connect($host, $user, $pwd) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$searchTerm = trim($_GET['searchname']);
// Check if $searchTerm is empty
if ($searchTerm == "") {
echo "Enter name you are searching for.";
exit();
} else {
$sql = "SELECT * FROM contractor WHERE CONCAT(FIRSTNAME,' ',LASTNAME,' ', ARRIVAL) like
'%$searchTerm%'";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
if (($count) >= 1) {
$output = "";
while ($row = mysql_fetch_array($query)) {
$output .= "First Name: " . $row['FIRSTNAME'] . "<br />";
$output .= "Last Name: " . $row['LASTNAME'] . "<br />";
$output .= "Arrival: " . $row['ARRIVAL'] . "<br />";
}
echo $output;
} else {
echo "There was no matching record for the name " . $searchTerm;
}
}
?>
this code above is where all the results print and I would like to regulate the repeating cases, also where the radio button per individual should be. finally this is the form page the hyperlink goes to where I would like to pre poppulate the code. Welcome Back Contractor. Please fill the following information in again below for today's visit.
First Name:
<input type="text" name="FIRSTNAME" id="FIRSTNAME" value="<?php echo $_POST['radio']; ?>"/>
Last Name:
<input type="text" name="LASTNAME" id="LASTNAME" value="<?php echo $_POST['radio']; ?>"/>
<form action="insert_submit.php" method="post" style="margin-left:35px;">
First Name: <input type="text" name="FIRSTNAME" id="FIRSTNAME"/>
Last Name: <input type="text" name="LASTNAME" id="LASTNAME"/>
Purpose: <input type="text" name="PURPOSE" id="PURPOSE"/>
<br />
Company:
<input type="text" name="COMPANY" id="COMPANY"/>
DL #:
<input type="text" name="DRIVERL" id="DRIVERL"/>
<input type="radio" name="STATUS" id="STATUS" value="CHECKED IN">Log In
<br/>
<input type="radio" name="STATUS" id="STATUS" value="CHECKED OUT">Log Out
<br/>
<input type="submit" value="Submit">
<br/>
</form>
I appreciate any help. i hope I was just complicating things and can easily solve my last few issues. thank!
$_POST['radio']in there. Also those input tags are outside of the form. - Jamie Kitson