hi this is my code which updates an attendance system, but I dont know how to insert attendance for first time. Where should I use insert query? it also shows error and not updating the table. Somebody please guide me
<?php
$connection=mysql_connect("localhost","root","") ordie(mysql_error()
$db=mysql_select_db("Project") or die(mysql_error());
$sql = "SELECT Fac_name FROM Faculty ORDER BY Fac_name ASC ";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<form name="Attendence" method="post" action="A.php">
<table style="text-align: left; padding: 5px;" cellpadding="0px" cellspacing="0px">
<tbody>
<tr>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Faculty Name</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Abesent</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Present</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Total present</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)) {
?>
<tr>
<td class="table1">
<? $id[] = $rows['Fac_name']; ?><? echo $rows['Fac_name'];?>
</td>
<td class="table1">
<input name="date[<? echo $rows['Fac_name']; ?>]" type="text" >
</td>
<td id="present">
<input type="radio" name="Present[<? echo $rows['Fac_name']; ?>]" checked="checked" >Present
</td>
<td id="absent">
<input type="radio" name="Absent[<? echo $rows['Fac_name']; ?>]" value="ABSENT">Absent
</td>
<td style="text-align: left; padding: 5px; border: 1px #000000 solid; height: 33px;"></td>
</tr>
<?php }?>
<tr>
<td colspan="7" style="vertical-align:middle; text-align: center;">
<br><br>
<input id="Submit" type="submit" name="Submit" value="Insert" style="text-align: center; background-color: #000000; color: #ffffff; border: 1px #000000 solid;">
</td>
</tr>
</tbody>
</table>
</form>
<?php
if(isset($_POST['Submit'])) {
foreach($_POST['Present'] as $id => $value) {
$date=$_POST['date'];
$present=$_POST['Present'];
$absent=$_POST['Absent'];
$sql = "INSERT INTO Attendence(Fac_name, date, Present, Absent) VALUES ('".$id."', '$date[$value]', '$present[$value]', '$absent[$value]', '".$value."') ";
$result = mysql_query($sql);
}
}
if($result) {
//header("location:A.php");
} else {
//print_r ($_POST);
echo "Your entry is not completed at this time.............";
}
if(isset($_POST['submitattend'])) {
set_time_limit(0);
$class1 = $_SESSION['bra'];
$q3 = mysql_query("Select Id from `Faculty` order by `Id` ASC"); // get all roll numbers
$count = mysql_num_rows($q3);
$j = 1;
while($q4 = mysql_fetch_array($q3)) {
if(isset($_POST['chk'.$j])) {
$v2 = $q7['finalattend']+1; //total attendance of student
$v3 = $q7['totalattend']+1; //total attendance taken by teacher
mysql_query("UPDATE `Attendence` SET `finalattend`='".$v2."', `totalattend`='".$v3."' where `attenduser`='".$v1."'") or die(mysql_error());
} else {
$v2=$q7['totalattend']+1;
mysql_query("UPDATE `Attendence` SET `totalattend`='".$v2."' where `attenduser`='".$v1."'") or die(mysql_error());
}
$j=$j+1;
}
header("Location: 12.html"); //logout after taking attendance..
}
?>
$date_value = $date[$value];
$present_value = $present[$value];
$absent_value = $absent[$value];
$check_result = mysql_query("selct count(*) from Attendence where Fac_name = '$id' AND date = '$date_value' AND Present = '$present_value' AND Absent = '$absent_value' ");
if($check_result == 0)
{
// insert query
}
else
{
// update query
}
I think your INSERT query line has Syntax error Please correct it . You have only three row names - Fac_name, date, Present, Absent but are inserting 5 values. Besides that quotes are not used correctly
Related
I dont know whats wrong with the code , when i search from march 3 - march 12 , the march 12 transaction does not show.
Thank you very much , this would help me a lot.
What I want is to show the march 12 transaction , like the e.g. given below .
I want it to show transactions from this date , to the date chosen.
E.G.
This is where I input it
Picture 1
March 3-12 Sample
Picture 2
March 3-13 Sample
Picture 3
This is my code
<head>
<script>
$(function() {
$( "#tabs" ).tabs();
$('a[rel*=facebox]').facebox();
$( ".datepicker" ).datepicker();
});
$(document).ready(function(){
// Write on keyup event of keyword input element
$("#searchme").keyup(function(){
// When value of the input is not blank
if( $(this).val() != "")
{
// Show only matching TR, hide rest of them
$("#searchTbl tbody>tr").hide();
$("#searchTbl td:contains-ci('" + $(this).val() + "')").parent("tr").show();
}
else
{
// When there is no input or clean again, show everything back
$("#searchTbl tbody>tr").show();
}
});
});
// jQuery expression for case-insensitive filter
$.extend($.expr[":"],
{
"contains-ci": function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
</script>
<script>
function goBack() {
window.history.back();
}
</script>
<?php include('session.php'); ?>
<?php include('header.php'); ?>
<?php include('navbar.php'); ?>
<style>
.logo1 {
position: absolute;
right: 45%;
font-family: ""Lucida Console", Monaco, monospace";
top: 0%;
width: 80%;
background-color:#F8F8FF;
color: black;
text-align: center;
}
h3{
font-size:20px;
font-family: "Arial";
}
table {
width:60%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: center;
}
#media print {
#page { margin: 0; }
body { margin: 1cm; }
#printPageButton {
display: none;
}
#e{
display:none;
}
.footer {
position: fixed;
left: 0;
font-family: ""Lucida Console", Monaco, monospace";
bottom: 0;
width: 100%;
background-color:#F8F8FF;
color: black;
text-align: center;
}
}
</style>
<?php
if(isset($_POST['salesbtn'])) {
$from = date('Y-m-d', strtotime($_POST['dayfrom']))." 00:00:01";
$to = date('Y-m-d', strtotime($_POST['dayto']))." 23:59:59";
?>
</head>
<body>
<div style="height:50px;"></div>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-0">
<br><img src="../upload/logo.jpg" class="logo1" style="height:50px; width:50px;" ><br>
<center><h1>Inventory Report</h1><h3> From (<?php echo $from; ?>) To (<?php echo $to; ?>)</h3>
<br>
<button id="printPageButton" class="btn btn-primary" onClick="window.print();">Print</button>
<button id="e" class="btn btn-primary" onclick="goBack()">Back</button>
<br><br>
<table width="100%" cellspacing="0" cellpadding="0" style="font-family:Arial Narrow, Arial,sans-serif; font-size:15px;" border="1">
<tr>
<th width="25%"><div align="center"><strong> Date </strong></div></th>
<th width="20%"><div align="center"><strong> User</strong></div></th>
<th width="20%"><div align="center"><strong>Action</strong></div></th>
<th width="20%"><div align="center"><strong>Product Name</strong></div></th>
<th width="20%"><div align="center"><strong>Quantity </strong></div></th>
</tr>
<?php
$iq=mysqli_query($conn,"select * from inventory left join product on product.productid=inventory.productid where inventory_date BETWEEN CAST('$from' AS DATE) AND CAST('$to' AS DATE) order by inventory_date desc ");
while($iqrow=mysqli_fetch_array($iq)){
?>
<tr>
<td class="hidden"></td>
<td><?php echo date('M d, Y h:i A',strtotime($iqrow['inventory_date'])); ?></td>
<td>
<?php
$u=mysqli_query($conn,"select * from `user` left join customer on customer.userid=user.userid left join supplier on supplier.userid=user.userid where user.userid='".$iqrow['userid']."'");
$urow=mysqli_fetch_array($u);
if($urow['access']==1){
echo "Admin";
}
elseif($urow['access']==2){
echo $urow['customer_name'];
}
else{
echo $urow['company_name'];
}
?>
</td>
<td align="right"><?php echo $iqrow['action']; ?></td>
<td align="right"><?php echo $iqrow['product_name']; ?></td>
<td align="right"><?php echo $iqrow['quantity']; ?></td>
</tr>
<?php
} }
?>
</tr> </td>
</br> </br>
<td style="color:red;" align="center"> Total:<?php
try {
require ("conn.php");
$stmt = $conn->prepare("SELECT SUM(sales_total) as 'test' FROM sales WHERE sales_date BETWEEN '$from' AND '$to'");
$stmt->execute();
$row=$stmt->fetch(PDO::FETCH_ASSOC);
echo $row['test'];
}
catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
</table>
</div>
</div>
</div>
<?php include('script.php'); ?>
<?php include('modal.php'); ?>
<?php include('add_modal.php'); ?>
<script src="custom.js"></script>
The problem is occurring because you are casting your $to value as a DATE, which implies a TIME portion of 00:00:00. The BETWEEN then fails because '2018-03-12 11:31:25' is not <= '2018-03-12 00:00:00'
Changing the CAST of $to to a DATETIME should fix the problem. i.e.
$iq=mysqli_query($conn,"select * from inventory left join product on product.productid=inventory.productid where inventory_date BETWEEN CAST('$from' AS DATE) AND CAST('$to' AS DATETIME) order by inventory_date desc ");
The date range picker won't work properly in my inventory report, but for the sales report it works properly.
E.g. From 2018-03-07 to 2018-03-08, the 2018-03-08 does not show in the report.
Picture of the report:
Here is my code
<head>
<script>
$(function() {
$( "#tabs" ).tabs();
$('a[rel*=facebox]').facebox();
$( ".datepicker" ).datepicker();
});
$(document).ready(function(){
// Write on keyup event of keyword input element
$("#searchme").keyup(function(){
// When value of the input is not blank
if( $(this).val() != "")
{
// Show only matching TR, hide rest of them
$("#searchTbl tbody>tr").hide();
$("#searchTbl td:contains-ci('" + $(this).val() + "')").parent("tr").show();
}
else
{
// When there is no input or clean again, show everything back
$("#searchTbl tbody>tr").show();
}
});
});
// jQuery expression for case-insensitive filter
$.extend($.expr[":"],
{
"contains-ci": function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
</script>
<script>
function goBack() {
window.history.back();
}
</script>
<?php include('session.php'); ?>
<?php include('header.php'); ?>
<?php include('navbar.php'); ?>
<style>
.logo1 {
position: absolute;
right: 45%;
font-family: ""Lucida Console", Monaco, monospace";
top: 0%;
width: 80%;
background-color:#F8F8FF;
color: black;
text-align: center;
}
h3{
font-size:20px;
font-family: "Arial";
}
table {
width:60%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: center;
}
#media print {
#page { margin: 0; }
body { margin: 1cm; }
#printPageButton {
display: none;
}
#e{
display:none;
}
.footer {
position: fixed;
left: 0;
font-family: ""Lucida Console", Monaco, monospace";
bottom: 0;
width: 100%;
background-color:#F8F8FF;
color: black;
text-align: center;
}
}
</style>
<?php
if(isset($_POST['salesbtn'])) {
$from=$_POST['dayfrom'];
$to=$_POST['dayto'];
?>
</head>
<body>
<div style="height:50px;"></div>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-0">
<br><img src="../upload/logo.jpg" class="logo1" style="height:50px; width:50px;" ><br>
<center><h1>Inventory Report</h1><h3> From (<?php echo $from; ?>) To (<?php echo $to; ?>)</h3>
<br>
<button id="printPageButton" class="btn btn-primary" onClick="window.print();">Print</button>
<button id="e" class="btn btn-primary" onclick="goBack()">Back</button>
<br><br>
<table width="100%" cellspacing="0" cellpadding="0" style="font-family:Arial Narrow, Arial,sans-serif; font-size:15px;" border="1">
<tr>
<th width="25%"><div align="center"><strong> Date </strong></div></th>
<th width="20%"><div align="center"><strong> User</strong></div></th>
<th width="20%"><div align="center"><strong>Action</strong></div></th>
<th width="20%"><div align="center"><strong>Product Name</strong></div></th>
<th width="20%"><div align="center"><strong>Quantity </strong></div></th>
</tr>
<?php
$iq=mysqli_query($conn,"select * from inventory left join product on product.productid=inventory.productid where inventory_date BETWEEN CAST('$from' AS DATE) AND CAST('$to' AS DATE) order by inventory_date desc ");
while($iqrow=mysqli_fetch_array($iq)){
?>
<tr>
<td class="hidden"></td>
<td><?php echo date('M d, Y h:i A',strtotime($iqrow['inventory_date'])); ?></td>
<td>
<?php
$u=mysqli_query($conn,"select * from `user` left join customer on customer.userid=user.userid left join supplier on supplier.userid=user.userid where user.userid='".$iqrow['userid']."'");
$urow=mysqli_fetch_array($u);
if($urow['access']==1){
echo "Admin";
}
elseif($urow['access']==2){
echo $urow['customer_name'];
}
else{
echo $urow['company_name'];
}
?>
</td>
<td align="right"><?php echo $iqrow['action']; ?></td>
<td align="right"><?php echo $iqrow['product_name']; ?></td>
<td align="right"><?php echo $iqrow['quantity']; ?></td>
</tr>
<?php
} }
?>
</tr> </td>
</table>
</div>
</div>
</div>
<?php include('script.php'); ?>
<?php include('modal.php'); ?>
<?php include('add_modal.php'); ?>
<script src="custom.js"></script>
EDITED:
This is my inventory.php
In here the user can input the range date from , to .
I dont know if this will help you guys.
I just want to know why it does not work well.
The problem is when i input 2018-03-08 - 2018-03-08 , the march 7 shows up but the march 8 wont show up.
<form action="total_inventory.php" method="post">
From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]"> To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]">
<input type="submit" value="Show Report" name="salesbtn" ></form>
EDITED:
Here is my inventory table
INVENTORY DATA TABLE
UPDATED:
This is the output , still does not show the transaction from march 7
Sample Updated
There is time also in your table so you have to search with time. means your from should be d-m-Y 00:00:01 and your to should be d-m-Y 23:59:59
Updated : concat your date variables like this.
// Assume `$_POST['dayfrom'] = 03/15/2018;`
// Assume `$_POST['dayto'] = 03/31/2018;`
$from = date('Y-m-d', strtotime($_POST['dayfrom']))." 00:00:01";
$to = date('Y-m-d', strtotime($_POST['dayto']))." 23:59:59";
echo $from; // if date is `03/15/2018` output like `2018-03-15 00:00:01`
echo $to; // if date is `03/31/2018` output like `2018-03-31 23:59:59`
// NOTE: check your date format is like this or not, then run the SQL query.
Updated Query:
$iq=mysqli_query($conn,"select * from inventory left join product on product.productid=inventory.productid where ( inventory_date BETWEEN CAST('$from' AS DATE) AND CAST('$to' AS DATE) ) order by inventory_date desc ");
This code outputs the image on the left, and what I'm looking for is the image on the right: https://s27.postimg.org/niua66jqr/archive.jpg
How do I output this table correctly? Is it a problem with the archive code or the style code?
.archive-container {
margin-top: 85px;
}
.archive-container h2 {
font-weight: normal;
margin-bottom: 30px;
}
.archive,
.year,
th {
font-family: 'Georgia', sans-serif;
font-weight: normal;
color: #a6a6a6;
font-size: 16px;
}
.archive:hover th,
.year:hover th {
color: #a6a6a6 !important;
opacity: 1 !important;
}
.archive a:link:hover {
color: #e69900 !important;
}
a:link {
font-weight: normal;
color: black;
/
}
table {
margin-right: 20px;
border-spacing: 25px 3px;
}
<div class="archive-container">
<h2><?php the_title(); ?></h2>
<script type="text/javascript">
var domainroot = "sitetitle.com"
function Gsitesearch(curobj) {
curobj.q.value = "site:" + domainroot + " " + curobj.qfront.value
}
</script>
<form action="http://www.google.com/search" method="get" onSubmit="Gsitesearch(this)">
<p class="search">Search:
<br />
<input name="q" type="hidden" class="texta" />
<input name="qfront" type="text" style="width: 186px; text-size: 12px; height: 14px;" />
</p>
</form>
<table id=arc>
<?php $query="SELECT YEAR(post_date) AS `year`, MONTH(post_date) as `month`, DAYOFMONTH(post_date) as `dayofmonth`, ID, post_name, post_title FROM $wpdb->posts WHERE post_type = 'article' AND post_status = 'publish' ORDER BY post_date DESC" ; $key=m d5($query);
$cache=w p_cache_get( 'mp_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults=$ wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_add( 'mp_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ($arcresults) { $last_year = 0; $last_month = 0; foreach ( $arcresults as $arcresult ) { $year = $arcresult->year;
$month = $arcresult->month; if ($year != $last_year) { $last_year = $year; $last_month = 0; ?>
<tr class=year>
<th>
<br />
<br />
<?php echo $arcresult->year; ?></th>
</tr>
<?php } if ($month !=$ last_month) { $last_month=$ month; ?>
<tr class=archive>
<th>
<?php echo $wp_locale->get_month($arcresult->month); ?></th>
<td></td>
</tr>
<?php } ?>
<tr class=archive>
<th>
<?php echo $arcresult->dayofmonth; ?></th>
<td id=p<?php echo $arcresult->ID; ?>>
<a href="/<?php echo $arcresult->post_name; ?>">
<?php echo strip_tags(apply_filters( 'the_title', $arcresult->post_title)); ?></a>
</td>
</tr>
<?php } } ?>
</table>
</div>
<!-- /end .container -->
Maybe:
<table width="200" border="1">
<tbody>
<tr>
<td>
<div>2017</div>
<div>Januari</div>
<div>1</div>
</td>
<td>Long title here</td>
</tr>
<tr>
<td>
<div>2016</div>
<div>Januari</div>
<div>1</div>
</td>
<td>Long title here</td>
</tr>
</tbody>
</table>
I have a page that seems to work fine other than updating new text to the database. Everytime I hit submit it just takes it back to the original data. Please let me know what is missing for this to successfully query old data and update new data.
if (isset($_POST["submit"]) && $_POST["submit"] == "Update Load")
{
for ($count = 1; $count <= 6; $count++)
{
$fields[$count] = "";
if (isset($_POST["field" . $count . ""]))
{
$fields[$count] = trim($_POST["field" . $count . ""]);
//echo $fields[$count] . "<br />";
}
}
$con = mysql_connect("", "", "");
mysql_select_db("", $con);
$carriername = mysql_real_escape_string($_POST['carriername']);
$contact = mysql_real_escape_string($_POST['contact']);
$phone = mysql_real_escape_string($_POST['phone']);
$rating = mysql_real_escape_string($_POST['rating']);
$info = mysql_real_escape_string($_POST['info']);
$insert = "UPDATE carrierinfo Set `carriername` = '$carriername', `contact` = '$contact', `phone` = '$phone', `rating` = '$rating', `info` = '$info' WHERE `id` = '$id';";
mysql_query($insert) or die(mysql_error());
$select = "SELECT `carriername` ,`contact` ,`phone` ,`rating` ,`info` ,`id` FROM `carrierinfo` ORDER BY `carriername` DESC;";
$result = mysql_query($select) or die(mysql_error());
}
if ($rating == "")
{
$rating = "3";
}
if (isset($_GET["id"]))
{
$con = mysql_connect("", "", "");
mysql_select_db("", $con);
$id = mysql_real_escape_string($_GET["id"]);
$select = "SELECT * FROM `carrierinfo` WHERE `id` = '$id'";
$result = mysql_query($select) or die(mysql_error());
$fields = mysql_fetch_array($result, MYSQL_BOTH);
mysql_close($con);
}
else
{
header("Location:board.php");
}
?>
</script>
<style ="text-align: center; margin-left: auto; margin-right: auto;"></style>
</head>
<body>
<div
style="border: 2px solid rgb(0, 0, 0); margin: 16px 20px 20px; width: 400px; background-color: rgb(236, 233, 216); text-align: center; float: left;">
<form action="" method="post";">
<div
style="margin: 8px auto auto; width: 300px; font-family: arial; text-align: left;"><br>
<table style="font-weight: normal; width: 100%; font-size: 12px;"
border="1" bordercolor="#929087" cellpadding="6" cellspacing="0">
<table
style="font-weight: normal; width: 100%; text-align: right; font-size: 12px;"
border="1" bordercolor="#929087" cellpadding="6" cellspacing="0">
<tbody>
<tr>
<td style="width: 35%;">Carrier Name:</td><td><input id="carriername" name="carriername" maxlength="50" style="width: 100%;" type="text" value="<?php echo $fields[carriername]; ?>">
</tr>
<tr>
<td style="width: 35%;">Contact:</td><td><input id="contact" name="contact" maxlength="50" style="width: 100%;" type="text" value="<?php echo $fields[contact]; ?>">
</tr>
<tr>
<td style="width: 35%;">Phone:</td><td><input id="phone" name="phone" maxlength="50" style="width: 100%;" type="text" value="<?php echo $fields[phone]; ?>">
</tr>
<tr>
<td style="width: 10%;">Carrier Rating:</td><td>
<select id="rating" name="rating">
<option value=""></option>
<option <?php if($fields[rating] == "1") echo "selected"; ?> value="1">1</option>
<option <?php if($fields[rating] == "2") echo "selected"; ?> value="2">2</option>
<option <?php if($fields[rating] == "3") echo "selected"; ?> value="3">3</option>
<option <?php if($fields[rating] == "4") echo "selected"; ?> value="4">4</option>
<option <?php if($fields[rating] == "5") echo "selected"; ?> value="5">5</option>
</select>
</td>
</tr>
<tr>
<td style="width: 10%;">Carrier Info:</td><td style="text-align: center;" colspan="2"><textarea name="info" maxlength="65535" style="width: 100%; height: 4em;"><?php echo $fields[info]; ?></textarea></td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><input name="submit" value="Update"
class="submit" type="submit"></p>
</div>
</form>
<input type="button" onclick="window.location.href='test3.php';" value="Back" />
</div>
<p style="margin-bottom: -20px;"> </p>
</body>
$insert = "UPDATE carrierinfo Set `carriername` = '$carriername', `contact` = '$contact', `phone` = '$phone', `rating` = '$rating', `info` = '$info' **WHERE `id` = '$id';**";
You haven't declared what $id should be before running your UPDATE query so nothing is being updated.
You are looking for
$_POST["submit"] == "Update Load"
but the value of your submit button is "Update", not "Update Load".
Ok I almost got a dropdown pulling from my DB and posting to it as well to work. I got it to pull down the data and for it to submit to the DB. Still a stump. If I have example "ABC Trucking" as an option. It only posts "ABC" to table1. For whatever reason it doenst post two words? Any Ideas? See where the carriername dropdown is in the div.
My Code:
<?php
if (isset($_POST["submit"]) && $_POST["submit"] == "Submit")
{
for ($count = 1; $count <= 9; $count++)
{
$fields[$count] = "";
if (isset($_POST["field" . $count . ""]))
{
$fields[$count] = trim($_POST["field" . $count . ""]);
//echo $fields[$count] . "<br />";
}
}
$con = mysql_connect("local", "user", "pass");
mysql_select_db("DB", $con);
$carriername = mysql_real_escape_string($_POST['carriername']);
$fromzip = mysql_real_escape_string($_POST['fromzip']);
$tozip = mysql_real_escape_string($_POST['tozip']);
$typeofequipment = mysql_real_escape_string($_POST['typeofequipment']);
$weight = mysql_real_escape_string($_POST['weight']);
$length = mysql_real_escape_string($_POST['length']);
$paymentamount = mysql_real_escape_string($_POST['paymentamount']);
$contactperson = mysql_real_escape_string($_POST['contactperson']);
$loadtype = mysql_real_escape_string($_POST['loadtype']);
$insert = "INSERT INTO table1 (`carriername` ,`fromzip` ,`tozip` ,`typeofequipment` ,`weight` ,`length` ,`paymentamount` ,`contactperson` ,`loadtype`) VALUES('$carriername' ,'$fromzip' ,'$tozip' ,'$typeofequipment' ,'$weight' ,'$length' ,'$paymentamount' ,'$contactperson' ,'$loadtype');";
mysql_query($insert) or die(mysql_error());
$select = "SELECT `carriername` ,`fromzip` ,`tozip` ,`typeofequipment` ,`weight` ,`length` ,`paymentamount` ,`contactperson` ,`loadtype` FROM `table1` ORDER BY `paymentamount` DESC;";
$result = mysql_query($select) or die(mysql_error());
}
?>
</script>
<style ="text-align: center; margin-left: auto; margin-right: auto;"></style>
</head>
<body>
<div
style="border: 2px solid rgb(0, 0, 0); margin: 16px 20px 20px; width: 400px; background-color: rgb(236, 233, 216); text-align: center; float: left;">
<form action="" method="post";">
<div
style="margin: 8px auto auto; width: 300px; font-family: arial; text-align: left;"><br>
<table style="font-weight: normal; width: 100%; font-size: 12px;"
border="1" bordercolor="#929087" cellpadding="6" cellspacing="0">
<table
style="font-weight: normal; width: 100%; text-align: right; font-size: 12px;"
border="1" bordercolor="#929087" cellpadding="6" cellspacing="0">
<tbody>
<tr>
<td style="width: 10%;">Carrier:</td><td>
<?php
$con = mysql_connect("local", "user", "pass");
mysql_select_db("DB", $con);
$query=("SELECT * FROM table2");
$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
echo "<select name=carriername>";
while($row=mysql_fetch_array($result)){
echo "<OPTION VALUE=".$row['carriername'].">".$row['carriername']."</OPTION>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td style="width: 35%;">Pick Zip:</td><td> <input id="fromzip" name="fromzip" maxlength="50"
style="width: 100%;" type="text">
</tr>
<tr>
<td style="width: 35%;">Drop Zip:</td><td> <input id="tozip" name="tozip" maxlength="50"
style="width: 100%;" type="text">
</tr>
<tr>
<td style="width: 35%;">Load Type:</td><td> <input id="loadtype" name="loadtype" maxlength="50"
style="width: 100%;" type="text">
</tr>
<tr>
<td style="width: 35%;">Rate:</td><td> <input id="paymentamount" name="paymentamount" maxlength="50"
style="width: 100%;" type="text">
</tr>
</tbody>
</table>
<p style="text-align: center;"><input name="submit" value="Submit"
class="submit" type="submit"></p>
</div>
</form>
</div>
<p style="margin-bottom: -20px;"> </p>
</body>
instead of :
echo "<OPTION VALUE=".$row['carriername'].">".$row['carriername']."</OPTION>";
use this
echo "<OPTION VALUE='".$row['carriername']."'>".$row['carriername']."</OPTION>";
notice ' in ur value...concate '' to your value attr.. so that it makes it a string....
EDITED
echo "<select name='carriername'>";
while($row=mysql_fetch_array($result)){
echo "<OPTION VALUE=".$row['carriername'].">".$row['carriername']."</OPTION>";
}
echo "</select>";