I'am trying to get some values from users and after that I'am inserting these values to my database but I can't get some of my select boxes's values using $_POST.
Users first select intership type via selectbox and depending on value of this selectbox the bottom menu changes via jQuery (That's why these IENG349ReqCourses and IENG449ReqCourses div's are hidden).
But I can't get the values of grade selecboxes inside of these hidden div's. Rest of input fields are okay, I can get their values and save to my database.
HTML:
<form id="intershipStage1Form" method="POST" action="form1.php">
<div id="generalInfo">
<center>
<table>
<tr>
<td colspan="2" valign="middle" align="center">
<label id="stuNameLabel">Student Full Name: <?php echo $_SESSION['username']; ?></label>
</td>
</tr>
<tr>
<td title="Your student number contains only numbers and should be 11 digits " valign="middle"><label id="stuNumberLabel">Student Number:</label></td>
<td><input id="stuNumberText" class="form1Text" type="text" name="stuNumberText" /></td>
</tr>
<tr>
<td title="A sample format: 3.16 and do not use comma(,)" valign="middle"><label id="stuGPALabel">Student GPA:</label></td>
<td><input id="stuGPAText" class="form1Text" type="text" name="stuGPAText" /></td>
</tr>
<tr>
<td title="Choose your academic advisor" valign="middle"><label id="stuAdvisorLabel">Student Advisor:</label></td>
<td align="center">
<select id="advisorSelectionBox" name="advisorSelectionBox">
<option value="">--select--</option>
<?php
$userType = "A";
$stmt = $db->prepare("SELECT * FROM users WHERE UserType = ?");
if($stmt == "false"){
die('Query error !'.$db->error);
}
$stmt->bind_param('s', $userType);
$stmt->execute();
$result = $stmt -> get_result();
while($advisor = $result ->fetch_array(MYSQLI_BOTH)){
echo '<option value="'.$advisor["UserID"].'">'.$advisor['FirstName']." ".$advisor['LastName'].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td title="Choose your current study year" valign="middle">
<label>Study Year:</label>
</td>
<td align="center">
<select id="studyYearBox" name="studyYearBox">
<option value="">--select--</option>
<option value="SOPHOMORE">SOPHOMORE</option>
<option value="JUNIOR">JUNIOR</option>
<option value="SENIOR">SENIOR</option>
</select>
</td>
</tr>
<tr>
<td title="Choose your internship type before try to sent this form to your advisor" valign="middle">
<label>Internship Type:</label>
</td>
<td align="center">
<select id="intershipTypeBox" name="intershipTypeBox">
<option value="">--select--</option>
<option value="IENG349">IENG 349</option>
<option value="IENG449">IENG 449</option>
</select>
</td>
</tr>
</table>
</center>
</div>
<div id="litleSpacer"></div>
<div id="IENG349ReqCourses" class="reqCourses" hidden="true">
<center>
<table>
<caption style="color:#f00;">Please select your grades</caption>
<tr>
<td valign="middle">
<label>IENG 102 - Intro to IE:</label>
</td>
<td>
<select name="IENG102Grade">
<option value="">--select--</option>
<option value="A">A</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B">B</option>
<option value="B-">B-</option>
</select>
</td>
</tr>
</table>
</center>
</div>
<div id="IENG449ReqCourses" class="reqCourses" hidden="true">
<center>
<table>
<caption style="color:#f00;">Please select your grades</caption>
<tr>
<td valign="middle">
<label>IENG 312 - System Simulation:</label>
</td>
<td>
<select name="IENG312Grade">
<option value="">--select--</option>
<option value="A">A</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B">B</option>
<option value="B-">B-</option>
</select>
</td>
</tr>
</table>
</center>
</div>
<div id="litleSpacer"></div>
<input id="sendButton" type="submit" name="sendButton" value="SEND FOR APPROVEMENT"/>
</form>
PHP:
<?php
$stuID = $_SESSION['user_id'];
$stuFullName = $_SESSION['username'];
$stuNumber = $_POST['stuNumberText'];
$stuGPA = $_POST['stuGPAText'];
$stuAdvisor = $_POST['advisorSelectionBox'];
$studyYear = $_POST['studyYearBox'];
$internshipType = $_POST['intershipTypeBox'];
$coordinatorAppr = "SENT";
$advisorAppr = "SENT";
$IENG102 = $_POST['IENG102Grade'];
$IENG312 = $_POST['IENG312Grade'];
$insert_stmt = $db->prepare("INSERT INTO internship_form_info VALUES(NULL,?,?,?,?,?,?,?,?,?)");
if($insert_stmt === false){
die('Query Error: '.$db->error);
}
$insert_stmt ->bind_param("sssssssii",$stuFullName,$stuNumber,$stuGPA,$studyYear,$internshipType,$advisorAppr,$coordinatorAppr,$stuID,$stuAdvisor);
$insert_stmt ->execute();
$formID = $db->insert_id;
if($internshipType=="IENG349"){
$insert_stmt2 = $db->prepare("INSERT INTO ieng349_req_courses_grades VALUES(NULL,?,?,?)");
if($insert_stmt2 === false){
die('Query Error: '.$db->error);
}
$insert_stmt2 ->bind_param("iisssssss",$stuID,$formID,$IENG102);
$insert_stmt2 ->execute();
}
else if($internshipType=="IENG449"){
$insert_stmt3 = $db->prepare("INSERT INTO ieng449_req_courses_grades VALUES(NULL,?,?,?)");
if($insert_stmt3 === false){
die('Query Error: '.$db->error);
}
$insert_stmt3 ->bind_param("iisssssssssssss",$stuID,$formID,$IENG312);
$insert_stmt3 ->execute();
}
$db->close();
So what can be the problem? Any help would be appriciated!
You have to make one option as selected to get it posted to the server.
If field is hidden and no option is marked selected, you will get no value on server.
I suggest to you, to check for example in Live Http Headers, which $_POST date you send. Also in your very top of script put
var_dump($_POST);
Related
I have a form of 5 fields. when click on submit button it will fetch Amount against the fields from database MSSQL. Now when i fill form and submit it is giving an error. i have used MSSQL procedure query to execute it. please help me out i am in trouble now.
<div id="middle_pane">
<div>
<div id="inner_pane">
<div id="center_pane">
<div id="center_inner_pane">
<div class="txt_content">
<table width="385" height="200" style=" border:2px solid silver"
cellpadding="6px" cellspacing="0px" align="center" border="0">
<form method="POST" action="<?php bloginfo('url');?>/fedex-tariff">
<tr>
<td colspan="2" style="background:#0066FF; color:#FFFFFF;
fontsize:50px">Fedex Rate Card</td></tr>
<tr>
<td>Origin</td>
<td>
<select name="origin" id="origin" onChange="">
<option value="pakistan">Pakistan</option>
</select>
</td>
</tr>
<tr>
<td>Select Origin city </td>
<td>
<select name="city_id" id="city_id">
<option value="">--SELECT CITY--</option>
<?php
$city = "select * from branches";
$city_query = mssql_query($city);
while ($row_city = mssql_fetch_array($city_query)){
?>
<option value="<?php echo $row_city['name'];?>"> <?php echo
$row_city['name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Select Destination </td>
<td>
<select name="country_id" id="country_id">
<option value="">--SELECT Destination--</option>
<?php
$service= "select * from country";
$service_query= mssql_query($service);
while ($row_service = mssql_fetch_array($service_query)){
?>
<option value="<?php echo $row_service['Name'];?>"> <?php
echo $row_service['Name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td> Selection of Weight </td>
<td>
<div id="wgt">
<input type="text" id="weight" name="weight" value=""
placeholder="weight...." required="">
</div>
</td>
</tr>
<tr>
<td>Select Your Service</td>
<td>
<select name="service_id" id="service_id">
<option value="">--SELECT--</option>
<?php
$service_type = "SELECT distinct ServiceTypeId from
dbo.IntlZoneCountry where ServiceTypeId IN ('FedEx Cash Tariff
Docs','FedEx Box','FedEx Student Package')";
$res_type = mssql_query($service_type);
$cnt_type = mssql_num_rows($res_type);
while($row_type = mssql_fetch_array($res_type)){
?>
<option value="<?php echo $row_type['ServiceTypeId'];?>"><?php
echo $row_type['ServiceTypeId'];?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td> <input type="submit" value="Calculate" name="submit"
class="btn"></td>
</tr>
</form>
<table width="385" style=" border:2px solid silver"
cellpadding="6px" cellspacing="0px" align="center" border="0">
<tr>
<td>
<?php
if(isset($_POST['submit']))
{
$city_id = $_POST['city_id'];
$country_id = $_POST['country_id'];
$service_id = $_POST['service_id'];
$weight_id = $_POST['weight'];
if(empty($city_id) || empty($country_id) || empty($service_id) ||
empty($weight_id)){
?><center><?php echo "Please filled all the fields first.";?>
</center>
<?php
}
else{
$s = "[SP_UpdateCNPrice_Int_Tariff]
'$weight_id','$city_id','$country_id','$service_id'";
$result = mssql_query($s);
while($row = mssql_fetch_assoc($result)){
?>
</td>
</tr>
<tr style="background:#00CFFF; color:blue;">
<td>
<center>
<font size="3">
<?php
$val = $row['amount'];
$gst = $row['gst'];
echo "<strong>"."Rate : "."$".""." ".$val.$gst;
?>
</font>
</center>
</td>
</tr>
<tr style="background:#00CFFF; color:blue;">
<td><center> All Rates are Exclusive of 16% GST + 23% fuel
Charges (FSC).</center> </td>
</tr>
<?php
}
}
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
MSSQL Procedure Screenshot
Front Display of Website
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have this form to input data into a MySQL database. It's not giving me any errors, but also not inserting data. I have looked around the web, with no avail. I'm not sure if it's my code or maybe I've misconfigured my database. Here's all the code.
<!DOCTYPE html>
<html>
<head>
<title>Steam Traps Form</title>
<style type="text/css">
table tr > td { text-align: right; }
table tr > td + td { text-align: left; }
</style>
</head>
<body>
<form action="FormHandler.php" method="post" >
<table border="0">
<tr>
<td align="center"><h1>Steam Trap Form Input</h1></td>
</tr>
<tr>
<td>
<tr>
<td>Date of Survey</td>
<td><input type="date" name="dateSurvey">
</td>
<tr>
<tr>
<td>Plant Name</td>
<td><input type="text" name="plantName"></td>
</tr>
<tr>
<td>Plant Location</td>
<td><input type="text" name="plantLoc"></td>
</tr>
<tr>
<td>Plant Contact Name</td>
<td><input type="text" name="plantContact"></td>
</tr>
<tr>
<td>Direction</td>
<td><select name="direction">
<option value="N">N</option>
<option value="NE">NE</option>
<option value="NW">NW</option>
<option value="S">S</option>
<option value="SE">SE</option>
<option value="SW">SW</option>
<option value="E">E</option>
<option value="W">W</option>
</select>
</td>
</tr>
<tr>
<td>Location (detailed as possible)</td>
<td><input type="text" name="location" size="40">
</td>
</tr>
<tr>
<td>Floor Level</td>
<td><select name="flrLevel">
<option value="grd">Ground</option>
<option value="1st">1st</option>
<option value="2nd">2nd</option>
<option value="3rd">3rd</option>
<option value="4th">4th</option>
<option value="5th">5th</option>
<option value="6th">6th</option>
<option value="7th">7th</option>
<option value="8th">8th</option>
<option value="9th">9th</option>
<option value="10th">10th</option>
<option value="11th">11th</option>
<option value="12th">12th</option>
<option value="13th">13th</option>
<option value="14th">14th</option>
<option value="15th">15th</option>
</select>
</td>
</tr>
<tr>
<td>Elevation (in ft)</td>
<td><input type="number" name="elevation" size="5">
</td>
</tr
<tr>
<td>Tag Number</td>
<td><input type="text" name="tagNum" size="20">
</td>
</tr>
<tr>
<td>MFG Model Number</td>
<td><input type="text" name="mmn" size="30">
</td>
</tr>
<tr>
<td>Size</td>
<td><input type="text" name="size" size="10">
</td>
</tr>
<tr>
<td>Pressure</td>
<td><input type="number" name="pressure" size="5">
</td>
</tr>
<tr>
<td>Service</td>
<td><input type="text" name="service" size="5">
</td>
</tr>
<tr>
<td>Trap Conditions</td>
<td><select name="trapCond">
<option value="OK">OK</option>
<option value="BT">BT</option>
<option value="RCL">RCL</option>
<option value="CP">CP</option>
<option value="VO">VO</option>
</select>
</td>
</tr>
<tr>
<td align="right"><input type="submit"
name="submit" value="Submit"></td>
</tr>
</form>
</td>
</tr>
</table>
<br />
</body>
</html>
Here is the PHP
<?php
$dateSurvey = $_POST["dateSurvey"];
$plantName = $_POST["plantName"];
$plantLoc = $_POST["plantLoc"];
$plantContact = $_POST["plantContact"];
$direction = $_POST["direction"];
$location = $_POST["location"];
$flrLevel = $_POST["flrLevel"];
$elevation = $_POST["elevation"];
$tagNumb = $_POST["tagNum"];
$mmn = $_POST["mmn"];
$size = $_POST["size"];
$pressure = $_POST["pressure"];
$service = $_POST["service"];
$trapCond = $_POST["trapCond"];
$sql_connection = mysql_connect("localhost", "******", "******");
mysql_select_db("******", $sql_connection) or die( "Unable to select database");
$sql = "INSERT INTO steamtraps (
dateSurvey,
plantName,
plantLoc,
plantContact,
direction,
location,
flrLevel,
elevation,
tagNum,
mmn,
size,
pressure,
service,
trapCond,
ContactDateCreated,
)
VALUES (
'{$dateSurvey}',
'{$plantName}',
'{$plantLoc}',
'{$plantContact}',
'{$direction}',
'{$location}',
'{$flrLevel}',
'{$elevation}',
'{$tagNum}',
'{$mmn}',
'{$size}',
'{$pressure}',
'{$service}',
'{$trapond}',
NOW()
)";
mysql_query($sql, $sql_connection);
mysql_close($sql_connection);
?>
Try to change the mysql_query to show errors meaningfully:
mysql_query($sql, $sql_connection) or die(mysql_error() . "<br/>Query was: " . $sql);
If you have an error, it will stop execution and you will see both the error and the query that was attempted to be executed.
I'm not sure what version of PHP you are running, but mysql_query and other related commands have been deprecated since PHP-5.5.0. http://php.net/manual/en/function.mysql-query.php
Try using the newer mysqli_query (you will need to update all of your sql commands like mysqli_connect and mysqli_close to match).
http://php.net/manual/en/mysqli.query.php
I am trying to store form data in a database using WampServer.
When I click on the submit button it shows me this error:
"Error: Champ 'product_name' inconnu dans field list".
I am using the same work for another form. That form is working but i dont know what is wrong with this one, Please help me out
My form code is :
<form action="saddproduct.php" enctype="multipart/form-data" name="myForm" id="myForm"
method="post">
<table width="90%" border="1" cellpadding="6">
<tr>
<td width="20%">Product Name</td>
<td width="80%">
<label>
<input name="product_name" type="text" id="product_name" size="60" />
</label>
</td>
</tr>
<tr>
<td width="20%">Product Code</td>
<td width="80%">
<label>
<input name="product_code" type="text" id="product_code" size="60" />
</label>
</td>
</tr>
<tr>
<td width="20%">Product Availability</td>
<td width="80%">
<label>
<select name="availability" id="availability">
<option value=""></option>
<option value="in"> In Stock </option>
<option value="out"> Out Of Stock </option>
</select>
</label>
</td>
</tr>
<tr>
<td width="20%">Product Price</td>
<td width="80%">
<label>
Rs.
<input name="price" type="text" id="price" size="12" />
</label>
</td>
</tr>
<tr>
<td align="right">Category</td>
<td>
<label>
<select name="category" id="category">
<option value=""></option>
<option value="living"> Living Rooms </option>
<option value="bed"> Bed Rooms </option>
<option value="dining"> Dining Rooms </option>
</select>
</label>
</td>
</tr>
<tr>
<td align="right">Sub category</td>
<td>
<label>
<select name="subcategory" id="subcategory">
<option value=""></option>
<option value="lsofa"> Lining Sofa </option>
<option value="lchair"> Living Chair </option>
<option value="ltable"> Living Table </option>
<option value="bking"> King Beds </option>
<option value="bqueen"> Queen Beds </option>
<option value="dtable"> Dining Tables </option>
<option value="dchairs"> Dining Chairs </option>
<option value="hsale"> Sale Item For Home Page </option>
<option value="psale"> Sale Item For Sale Page </option>
</select>
</label>
</td>
</tr>
<tr>
<td width="20%">Product Detail</td>
<td width="80%">
<label>
<textarea name="details" id="details" cols="64" rows="5"> </textarea>
</label>
</td>
</tr>
<tr>
<td> </td>
<td width="80%">
<label>
<input type="submit" name="button" id="button" class="button" value="Add This
Product Now" />
</label>
</td>
</tr>
<tr>
<td width="20%"> </td>
<td width="80%"> </td>
</tr>
</table>
</form>
And my processing PHP page is saddproduct.php which look like :
<?php
$con=mysqli_connect("localhost","root","03005225400","furniture");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$product_name = mysqli_real_escape_string($con, $_POST['product_name']);
$product_code = mysqli_real_escape_string($con, $_POST['product_code']);
$availability = mysqli_real_escape_string($con, $_POST['availability']);
$price = mysqli_real_escape_string($con, $_POST['price']);
$category = mysqli_real_escape_string($con, $_POST['category']);
$subcategory = mysqli_real_escape_string($con, $_POST['subcategory']);
$details = mysqli_real_escape_string($con, $_POST['details']);
$sql="INSERT INTO employee
(product_name , product_code, availability, price,
category, subcategory, details, date_added)
VALUES('$product_name','$product_code', '$availability',
'$price','$category','$subcategory','$details',now())"
or die (mysql_error());
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
mysqli_close($con);
?>
I am sure that if you verify your table structure you wont find any column named product_name, at least not with the exact case.
Try verifying your column names, and if you still dont have a clue, try removing column names and sticking to the order of your table structure while putting NULL in fields with default content like auto increment and timestamps.
Simple typo. Table employee should be products
Sometimes this(Error: Champ 'Yes' inconnu dans field list) type error occurs due to using (`) this single quotes rather than using (') this quotes in INSERT query.
The very first field named Forte ID posts a value of 0 no matter what selection I choose. Here are my two files:
Index.php(Form)
</head>
<h1> Customer Service Log Form </h1>
<form method="post" action="insert.php">
<table width="625" border="0">
<tr>
<td> Forte ID:</td>
<td><select id="ForteID" name="ForteID">
<option value="0">Select Your ID</option>
<option value="as7326">as7326</option>
<option value="aw8743">aw8743</option>
<option value="bj0920">bj0920</option>
<option value="bs1441">bs1441</option>
<option value="dk7017">dk7017</option>
<option value="dl7686">dl7686</option>
<option value="dm2940">dm2940</option>
<option value="jn2468">jn2468</option>
<option value="jw9598">jw9598</option>
<option value="kp4945">kp4945</option>
<option value="nl2589">nl2589</option>
<option value="rp7021">rp7021</option>
<option value="sh1346">sh1346</option>
</select></td>
</tr>
<tr>
<td> Disposition</td>
<td><select id="disposition" name="disposition">
<option value="0">Select a Disposition</option>
<option value="Save">Save</option>
<option value="Sale">Sale</option>
<option value="LOC">LOC</option>
<option value="Backout">Backout</option>
<option value="Revision">Revision</option>
<option value="Revision">Revision/Save</option>
</select>
</td>
</tr>
</table>
<hr />
<br />
<table width="400" border="0">
<tr>
<td>App Number:</td>
<td></td>
<td><input name="appnumber" type="text" required="required"></td>
</tr>
<tr>
<td>Finance Number:</td>
<td></td>
<td><input type="text" name = "Finance_Num"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td></td>
<td><input type="text" name = "Phone_Num"></td>
</tr>
<tr>
<td># of Payments Collected:</td>
<td></td>
<td><input type="text" name = "num_payments"></td>
</tr>
<tr>
<td>ACH/CC</td>
<td></td>
<td><select id="ForteID" name="ForteID">
<option value="0">Select Payment</option>
<option value="ach">Checking</option>
<option value="cc">Credit Card</option>
</select></td>
</tr>
<tr>
<td>Date:</td>
<td></td>
<td><input name = "date" type="text" id="datepicker" autocomplete="off" required="required"></td>
</tr>
</table>
<br />
Notes:
<br />
<textarea name="notes" id="notes" cols="45" rows="5"></textarea>
</fieldset>
<hr />
<input type="Submit" name="formSubmit" value="Submit">
<input type="Reset" name="formReset" value="Reset">
<input type="button" value="View Logs" onClick="window.location.href='logs.php';">
</form>
</head>
Insert.php (PHP file to insert data from form into SQL Server Database):
$serverName = 'Server\SQLEXPRESS';
$connectionInfo = array('Database'=>'database', 'UID'=>'username', 'PWD'=>'password');
$connection = sqlsrv_connect($serverName, $connectionInfo);
if( $connection === false )
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
$tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, num_payments, ach_cc, date, notes, Phone_Num) VALUES (?,?,?,?,?,?,?,?,?)";
$parameters = array( $_POST[ForteID], $_POST[disposition], $_POST[appnumber], $_POST[Finance_Num], $_POST[num_payments], $_POST[ach_cc], $_POST[date], $_POST[notes], $_POST[Phone_Num]);
$stmt = sqlsrv_query($connection, $tsql, $parameters);
if( $stmt === false ){
echo "Statement could not be executed.\n";
die( print_r( sqlsrv_errors(), true));
} else {
echo "Rows affected: ".sqlsrv_rows_affected( $stmt )."\n";
}
No matter what option is selected in the index.php field Forte ID, it posts a value of 0. What is wrong. It was working before I added a field named Phone Number. But doesnt make sense why that would screw up the selections.
Let me know if I need to clarify anything and thanks for the help in advance!
You have to fields called ForteID
<select id="ForteID" name="ForteID">
<option value="0">Select Payment</option>
<option value="ach">Checking</option>
<option value="cc">Credit Card</option>
is the 2nd one
Happy New Year Everyone!
I have this existing php code I did when I first started and I was wondering if there a way to make it OOP or if I should find another way of recreating it. All opinions welcome.
<?php
require("local_php.inc");
DatabaseConnect();
//Variables to post to results.php
$keyword=$_POST['keyword'];
$location=$_POST['location'];
$type=$_POST['type'];
//Query
$q1 = "SELECT ssearch.id, ssearch.Company, ssearch.Address, ssearch_state.state_location, ssearch.City, ssearch.Zip, ssearch.Phone, ssearch.Description, ssearch.Email,
ssearch_event.Event_name FROM
(ssearch LEFT OUTER JOIN ssearch_state ON ssearch.State = ssearch_state.id)
LEFT OUTER JOIN ssearch_event ON ssearch.Event_id = ssearch_event.id
WHERE ssearch.Company LIKE '%$keyword%'";
if($location != "all")
{
$q1 .= "AND ssearch_state.state_location ='$location' ";
}
if($type != "all")
{
$q1 .= "AND ssearch_event.Event_name ='$type' ";
}
$q1 .= "ORDER BY ssearch.Company DESC LIMIT 0, 3;";
$result = mysql_query($q1);
$q1_total_rows = mysql_num_rows($result);
?>
<div id="content">
<?php if($q1_total_rows >= 1) { ?>
<?php while ($record = mysql_fetch_assoc($result)) { ?>
<div id="table">
<table width="379" height="64" border="0" align="left" bordercolor="#FFFF00" bgcolor="#FEFFD5">
<tr>
<td width="187"><p align="center" class="contentfontsmallsearch"><?php echo $record["Company"];?></p></td>
<td width="182"><p align="center" class="contentfontsmallsearch"><?php echo $record["Event_name"];?></p></td>
</tr>
<tr>
<td><p align="center" class="contentfontsmallsearch"><?php echo $record["state_location"];?></p></td>
<td><p align="center" class="contentfontsmallsearch"><?php echo $record["Description"];?></p></td>
<tr>
</table>
</div>
<?php } ?>
<? } else { ?>
<div id="table2">
<h3 align="center" class="noresults">No Results</h3><br />
<p align="center" class="contentfontsmallsearch">Please Try your Search Again</p><br />
<form action="results.php" method="post" name="myform" id="myform">
<table width="379" height="190" border="0" align="left" bordercolor="#FFFF00" bgcolor="#FEFFD5">
<tr>
<td width="143"><p align="center" class="contentfontsmallsearch">Keyword</p></td>
<td width="226">
<label>
<input name="keyword" type="text" id="keyword" size="30" />
</label>
</td>
</tr>
<tr>
<td><p align="center" class="contentfontsmallsearch">Location</p></td>
<td>
<select name="location">
<option value="all" selected="selected">All Locations</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="New Jersey">New Jersey</option>
<option value="Delaware">Delaware</option>
</select>
</td>
<tr>
<td width="143"><p align="center" class="contentfontsmallsearch">Event Type </p></td>
<td>
<select name="type">
<option value="all" selected="selected">All Events</option>
<option value="Rally Event">Rally Event</option>
<option value="Awareness Event">Awareness Event</option>
<option value="Donation Event">Donation Event</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit2" value="Search" /></td>
</tr>
</table>
</form>
</div>
<? } ?>
</div>
I would prefer if you first made it secure. Add mysql_real_escape_string when reading the $_POST input variables. As it stands now, your code relies on magic_quotes to work at all.
As second step, you could make this code procedural. Devise a location_query() function or something. I see no immediate structure that would benefit to jump to "making it OOP".