Avoid empty lines in php checkbox - php

I have html form wherein 7 check box are there. When all the boxes are checked, it is giving good result. Whereas any body gives 3 or 4 check, it shows the result with empty lines in between. It looks very indecent. Any body can suggest the corrective code for that.
the HTML code for the check box:
CONDITIONS: <br />
<input type="checkbox" name="c1" value="Invoice">Invoice <br />
<input type="checkbox" name="c2" value="LR copy">LR copy <br />
<input type="checkbox" name="c3" value="Test Reports">Test Reports<br />
<input type="checkbox" name="c4" value="Draft"> Draft<br />
<input type="checkbox" name="c5" value="Check-list">Check-List <br />
<input type="text" name="c6" placeholder=" Add any" maxlength="25" size="40"><br />
<input type="text" name="c7" placeholder=" Add any clause" maxlength="25" size="40">
the php code for the above check-box:
<html>
<head>
<style type="text/css">
table { margin: 1em 0 0 0; border-collapse: collapse; }
td {margin: 5px 0 0 0;padding: .4em ; border: 0px solid; height: 12px; }
tr td:first-child {font-weight: bold; width: 250px; color: black; height: 10px; font-size: 18px;}
tr td:last-child {width: 450px; color: blue;height: 10px; font-size: 18px; }
p {margin: 5px 0 0 20px; width: 700px; line height: 20px; text-align: justify; font-size:105%;
font-family: Arial, "Lucida Sans Unicode", Verdana, sans-serif;}
#trim {margin: 5px 0 0 20px; width: 700px; line height: 20px; text-align: center; font-size:150%;
font-family: Arial, "Lucida Sans Unicode", Verdana, sans-serif;}
.z{ margin: 5px 0 0 20px; width: 700px;}
.z1{ margin: 5px 0 0 20px; width: 700px;}
</style>
</head>
<body>
<div id="trim">
<b> FORMAT </b>
<hr size="2" noshade>
</div>
<?
$k1 = strtoupper($_REQUEST['k1']);
$k2 = strtoupper($_REQUEST['k2']);
$k3 = strtoupper($_REQUEST['k3']);
$k4 = strtoupper($_REQUEST['k4']);
$k5 = strtoupper($_REQUEST['k5']);
$k6 = strtoupper($_REQUEST['k6']);
$k7 = strtoupper($_REQUEST['k7']);
$k22 = strtoupper($_REQUEST['k22']);
$k23 = strtoupper($_REQUEST['k23']);
$k8 = strtoupper($_REQUEST['k8']);
$k9 = strtoupper($_REQUEST['k9']);
$k10 = strtoupper($_REQUEST['k10']);
$k11 = strtoupper($_REQUEST['k11']);
$k12 = strtoupper($_REQUEST['k12']);
$k13 = strtoupper($_REQUEST['k13']);
$k14 = strtoupper($_REQUEST['k14']);
$k15 = strtoupper($_REQUEST['k15']);
$k16 = strtoupper($_REQUEST['k16']);
$c6 = strtoupper($_REQUEST['c6']);
$c7 = strtoupper($_REQUEST['c7']);
$k19 = strtoupper($_REQUEST['k19']);
$k20 = strtoupper($_REQUEST['k20']);
$k21 = strtoupper($_REQUEST['k21']);
$r1 = strtoupper($_REQUEST['r1']);
$r2 = strtoupper($_REQUEST['r2']);
$r3 = strtoupper($_REQUEST['r3']);
$r4 = strtoupper($_REQUEST['r4']);
$r5 = strtoupper($_REQUEST['r5']);
$r6 = strtoupper($_REQUEST['r6']);
$r7 = strtoupper($_REQUEST['r7']);
$r8 = strtoupper($_REQUEST['r8']);
$r9 = strtoupper($_REQUEST['r9']);
$r10 = strtoupper($_REQUEST['r10']);
$c1 = strtoupper($_REQUEST['c1']);
$c2 = strtoupper($_REQUEST['c2']);
$c3 = strtoupper($_REQUEST['c3']);
$c4 = strtoupper($_REQUEST['c4']);
$c5 = strtoupper($_REQUEST['c5']);
$c8 = strtoupper($_REQUEST['c8']);
$c9 = strtoupper($_REQUEST['c9']);
$c10 = strtoupper($_REQUEST['c10']);
$c11 = strtoupper($_REQUEST['c11']);
$c12 = strtoupper($_REQUEST['c12']);
$c13 = strtoupper($_REQUEST['c13']);
$c14 = strtoupper($_REQUEST['c14']);
$c15 = strtoupper($_REQUEST['c15']);
$c16 = strtoupper($_REQUEST['c16']);
$c17 = strtoupper($_REQUEST['c17']);
$c18 = strtoupper($_REQUEST['c18']);
$c19 = strtoupper($_REQUEST['c19']);
$c20 = strtoupper($_REQUEST['c20']);
$c21 = strtoupper($_REQUEST['c21']);
$c22 = strtoupper($_REQUEST['c22']);
$c23 = strtoupper($_REQUEST['c23']);
$c24 = strtoupper($_REQUEST['c24']);
$c25 = strtoupper($_REQUEST['c25']);
$p1= strtoupper($_REQUEST['p1']);
$p2 = strtoupper($_REQUEST['p2']);
if(empty($k2)){$kk=" "; }else{$kk="(Code: $k2)";}
$html = "<p> <div class='z1'>
<b><u> PROJECT DETAILS </u></b>
<table>
<tr><td> Project Name: </td> <td > $k1 $kk</td></tr>
<tr><td> Purchase Order no:</td> <td > $k3 Dtd: $k4</td></tr>
<tr><td>Total Order Value:</td> <td >$k6 </td></tr>
<tr><td> Materials Ordered </td> <td >$k5 </td></tr>
<tr><td> Supplier Details: </td> <td >$k22 <br /> $k23</td></tr>
</table>
<br /><b><u> DISPATCH CONDITIONS </u></b>
<table>
<tr><td> Shipment from: </td> <td > $k11</td></tr>
<tr><td> Shipment to: </td> <td >$k12 </td></tr>
<tr><td> Dispatch starting date: </td> <td >$k9 </td></tr>
<tr><td> Last date of dispatch: </td> <td >$k10 </td></tr>
<tr><td> Part-Shipment: </td> <td >$r1 </td></tr>
<tr><td> Part-Transshipment: </td> <td > $r2</td></tr>
<tr><td> Transport Charges: </td> <td > $r4</td></tr>
<tr><td> Insurance Charges: </td> <td > $r3</td></tr>
<tr><td> Basis of price: </td> <td > $r5</td></tr>
</table>
<br /><b><u> BANK DETAILS </u></b>
<table>
<tr><td> L/C amount: </td> <td > $k8 <br /> Rs. $k30 </td></tr>
<tr><td> Usance period: </td> <td > $r9 Days from the date of dispatch.</td></tr>
<tr><td> Usance interest: </td> <td>$k15 Days to Supplier A/c. and $k16 Days to Buyer A/c.</td></tr>
<tr><td> Usance interest charges: </td> <td >Not more than $k14 % p.a </td></tr>
<tr><td> L/C Charges: </td> <td > Opening charges to $r7 and discount charges to $r8</td></tr>
<tr><td> Negotiation to be done: </td> <td > within $r10 Days from the date of dispatch.</td></tr>
<tr><td> Place of Expiry: </td> <td > $k21</td></tr>
</table>
<br /><b><u> DOCUMENTS REQUIRED:</u></b>
<ul><li>$c1
</li><li>$c2
</li><li>$c3
</li><li>$c4
</li><li>$c5
</li><li>$c6
</li><li>$c7
</li></ul>
<br /><b><u> L/C CONDITIONS </u></b>
<ul><li>
$c8 </li><li>
$c9 </li><li>
$c10</li><li>
$c11 </li><li>
$c12</li><li>
$c13 </li><li>
$c22 </li><li>
$c23 </li></ul>
<br /><b><u> ADDITIONAL CONDITIONS </u></b>
<ul><li>
$c14 </li><li>
$c15 </li><li>
$c16 </li><li>
$c17 </li><li>
$c18 </li><li>
$c19 </li><li>
$c20 </li><li>
$c21 </li><li>
$c24 </li><li>
$c25 </li><li>
$k19 </li><li>
$k20 </li></ul>
</div></p>";
$html .= "<div class='z'> <hr /> Place: <b>".$p1."</b></div>";
$html .= "<div class='z'> Date: $p2 <div style='float:right;font-size: 12pt'><i> (Authorized Signature ) </i></div></div>";
print($html);
?>
</body>
</html>

You are always echoing all the lines. when some values are empty, there will be just empty line (list item). So you have to check that the values exists. Little example:
<?
$html = '<p>CONDITIONS:</p><ul>';
function echoRow(&$html, $val) {
if (isset($val) && !empty($val))
$html .= '<li>' . $val . '</li>';
}
echoRow($c1);
echoRow($c2);
echoRow($c3);
echoRow($c4);
echoRow($c5);
echoRow($c6);
echoRow($c7);
$html .= '</ul>';
print($html);
?>

This is because when a checkbox is not checked, then its value is not send to server. For example if C1 is not checked, then it is not send in $_POST values. What you can do is check if each of checkbox is set and display only those whose value exits. If you want you can show alternative message for checkbox that is not set. You can do something like this
$html="<ul>";
if(isset($c1))
$html.="<li>$c1</li>"
else
{
//do nothing or show alternative message
$html.="<li>Invoice not selected</li>"
}
// do same for $c2....$c7
$html.="</ul>";
print($html);

Related

Why is DataTable only loading 5 out of 22 records in PHP/MySql?

I am certain that I am missing something small here but it had me going for 2 days now.
I am doing a SELECT STATEMENT with criteria, populate a DataTable and view records. My problem is that only 5 records is loaded whilst there are 22 records available. I did echo out each line and 22 is returned, not sure where my problem is and I will appreciate any help please.
I have a suspicion that the problem might be in the next line of code where the User_Role is to be returned, no errors though so I am not sure -
$resultUser = $db->get_row_by_field($User_Role_Data,$part_result->userID,'ID');
Code for Datatable (I played around with all options here, not helping) -
<script id="rendered-js">
$(document).ready(function () {
$("table").DataTable({
dom: "<'dt-head clearfix'lrf>t<'dt-foot clearfix'ip>",
bServerSide: false,
deferRender: false,
pageLength: 3,
autoWidth: false,
fixedHeader: true,
responsive: true,
language: {
search: "_INPUT_",
searchPlaceholder: "Search Item",
lengthMenu: "<select>" +
'<option value="10">10</option>' +
'<option value="25">25</option>' +
'<option value="50">50</option>' +
'<option value="100">100</option>' +
'<option value="-1">All</option>' +
"</select> View Rows Per Page",
oPaginate: {
sNext: "<i class='fa fa-mail-forward'></i>",
sPrevious: "<i class='fa fa-mail-reply'></i>"
}
}
});
});
This is the PHP code that returns the records, as above, return is fine, displaying is only 5 -
<tbody>
<?php
$total = 0;
$dealer_id = $user->dealerID;
$part_results = $db->get_results("SELECT * FROM wp_ims_part_booked WHERE dealerid='".$dealer_id."' AND isInvoiced='0' AND isCancelled='0' ORDER BY date_booked ASC");
if(count($part_results)>0){
foreach($part_results as $part_result){
$result = $db->get_row_by_field($part_result->partTable,$part_result->partID,'ID');
$bookingID = $db->get_row_by_field($part_result->partTable,$part_result->bookingID,'ID');
switch($part_result->user_role) {
case "Franchise Dealer":
$User_Role_Data = "wp_ims_user_dealer";
break;
case "OEM Retailer":
$User_Role_Data = "wp_ims_user_oem";
break;
case "Non-OEM Part Retailer":
$User_Role_Data = "wp_ims_user_non_oem";
break;
case "Insurance Company":
$User_Role_Data = "wp_ims_user_insurance";
break;
case "Panel/Body Repair Shop":
$User_Role_Data = "wp_ims_user_panel";
break;
case "Private Individual":
$User_Role_Data = "wp_ims_user_public";
break;
case "Non-Franchise Workshop":
$User_Role_Data = "wp_ims_user_non_franchise_wshop";
}
$resultUser = $db->get_row_by_field($User_Role_Data,$part_result->userID,'ID');
?>
<tr>
<td style="color: #0d9b84; text-align: center; width: 30px;">
<?php echo "#".$part_result->ID?>
</td>
<td style="color: #0d9b84; text-align: center; width: 80px;">
<?php echo $result->partnumber;?>
</td>
<td style="color: #0d9b84; text-align: center; width: 200px;">
<?php echo $result->partdescription;?>
</td>
<td style="color: #0d9b84; text-align: center; width: 70px;">
<?php echo "R ".number_format(($part_result->value_booked_for), 2);?>
</td>
<td style="color: #0d9b84; text-align: center; width: 220px;">
<?php echo "Client: ".$resultUser->name." ".$resultUser->surname;
echo "<br>";
echo "Contact No: ".$resultUser->contactnumber;
echo "<br>";
echo "City: ".$resultUser->usercity;
echo "<br>";
echo "Province: ".$resultUser->userprovince;
?>
</td>
<td style="color: #0d9b84; text-align: center; width: 100px;">
<?PHP
echo $part_result->date_booked;
?>
</td>
<td style="color: #0d9b84; text-align: center; width: 250px;">
<input type="hidden" name="ID" value="<?php echo $part_result->ID;?>" />
<input type="hidden" name="bookingID" value="<?php echo $bookingID;?>" />
<textarea rows="2" cols="30" class="contact-form-text" style="width: 100%; margin-top: 3px;" placeholder="ENTER YOUR NOTE (Required On Cancel)" required></textarea>
<a href="ims_cancel_client_purchase.php?ID=<?php echo $part_result->ID;?>&bookingID=<?php echo $bookingID;?>" class="btn btn-warning btn-block" style="color: #edf61a;">
Cancel Purchase X
<i class="fa fa-angle-right"></i>
</a>
<a href="ims_invoice_to_client.php?ID=<?php echo $part_result->ID;?>&bookingID=<?php echo $bookingID;?>" class="btn btn-success btn-block" style="color: #4cff00;">
Invoice To Client
<i class="fa fa-angle-right"></i>
</a>
<br />
</td>
</tr>
<?php
}
?>
<?PHP } else { ?>
<tr>
<th style="width:900px; text-align: center; font-weight: 600; font-size: 16px; color: #ff6a00;" class="min-tablet-l">
No Outstanding Orders or Bookings found for your Dealership.
</th>
</tr>
<?php } ?
Further notice (see image), the last record does not show the far right column buttons or textarea box, not sure why.

Can't send checklist to email from html

I need to do a simple script with two parts. First one is sending just name, phone number etc. and works perfectly already:
But after it i need to send a checklist to the same email, but still is nothing there.
My html:
<form action="contact.php" method="post" id="form" class="contact-form">
<table style="color: DEB441; font-size: 19px; margin-left: 60px; margin-top: 40px; float: left;">
<tr>
<td><font color="FFFFFF">Imie:</td>
<td style="padding:0px">
<textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_imie" rows="2" cols="20"></textarea>
</td>
</tr>
<tr>
<td><font color="FFFFFF">Nazwisko:</td>
<td style="padding:0px">
<textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_nazwisko" rows="2" cols="20"></textarea>
</td>
</tr>
<tr>
<td><font color="FFFFFF">Adres:</td>
<td style="padding:0px">
<textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_adres" rows="2" cols="20"></textarea>
</td>
</tr>
<tr>
<td><font color="FFFFFF">Telefon</td>
<td style="padding:0px">
<textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_telefon" rows="2" cols="20"></textarea>
</td>
</tr>
<tr>
<td><font color="FFFFFF">E-mail:</td>
<td style="padding:0px">
<textarea style="outline-color: FFFFFF; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_email" rows="2" cols="20"></textarea>
</td>
</tr>
<tr>
<td style="width: 150px;">
<p style="align: left; margin-top: 2px; margin-right: 10px;"><br>
<font style="font-size: 16px;" color="#FFFFFF" align="left">
Wybierz produkty:<br><br>
<font style="font-size: 12px;" color="#FFFFFF" align="left">
Herbatniki w pudelkach <br>
<hr align="left" width="110px"><bt>
<input type="checkbox" name="thenderese" value="thenderese" />Thenderese<br>
<input type="checkbox" name="petipa" value="petipa" />Petipa<br>
<input type="checkbox" name="biscripts" value="biscripts" />Biscripts<br>
</p>
</td>
<td style="width: 150px;">
<p style="width: 250px; align: left;"><br>
<font style="font-size: 12px;" color="#FFFFFF" align="left">
Herbatniki Pakowane pojedynczo<br>
<hr align="left" width="160px">
<input type="checkbox" name="6g" value="g6g" />6g
<input type="checkbox" name="150g" value="g150g" />150g
<input type="checkbox" name="300g" value="g300g" />300g
</p>
</td>
</tr>
<tr>
<td style="width: 200px; margin-right: 250px;">
<p align="left" style="align: left; margin-top:0px;"><br>
<font style="font-size: 12px;" color="#FFFFFF" align="left">
Inne
<hr align="left" width="150px">
<input type="checkbox" name="folia" value="folia">Biscripts opakowane w folie<br>
<input type="checkbox" name="speculoos1" value="speculoos1" />1,5 kg (proszek speculoos)<br>
<input type="checkbox" name="speculoos2" value="speculoos2" />1,1 kg (pokruszony speculoos)<br>
<input type="checkbox" name="krem" value="krem biscripts" />krem biscripts<br>
</p>
</td>
</tr>
</table>
</form>
and my PHP
<?php
$field_imie = $_POST['cf_imie'];
$field_nazwisko = $_POST['cf_nazwisko'];
$field_adres = $_POST['cf_adres'];
$field_telefon = $_POST['cf_telefon'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'serwis#reskomp.pl';
$subject = 'nowe zamowienie '.$field_imie;
$body_message = 'Od: '.$field_imie."\n";
$body_message .= 'Nazwisko: '.$field_nazwisko."\n";
$body_message .= 'Adres: '.$field_adres."\n";
$body_message .= 'Telefon: '.$field_telefon."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= 'Szczegoly zamowienia: '.$field_message;
$thenderese = $_POST['thenderese'];
if ($thenderese != 'Yes') {
$thenderese = 'No';
}
$petipa = $_POST['petipa'];
if ($petipa != 'Yes') {
$petipa = 'No';
}
$biscripts = $_POST['biscripts'];
if ($biscripts != 'Yes') {
$biscripts = 'No';
}
$g6g = $_POST['6g'];
if ($g6g != 'Yes') {
$g6g = 'No';
}
$g150g = $_POST['150g'];
if ($g150g != 'Yes') {
$g150g = 'No';
}
$g300g = $_POST['300g'];
if ($g300g != 'Yes') {
$g300g = 'No';
}
$folia = $_POST['folia'];
if ($folia != 'Yes') {
$folia = 'No';
}
$speculoos1 = $_POST['speculoos1'];
if ($speculoos1 != 'Yes') {
$speculoos1 = 'No';
}
$speculoos2 = $_POST['speculoos2'];
if ($speculoos2 != 'Yes') {
$speculoos2 = 'No';
}
$krem = $_POST['krem'];
if ($krem != 'Yes') {
$krem = 'No';
}
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Zamowienie zostalo przyjete do realizacji.');
window.location = '../herbatniki/index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Blad wysylania wiadomosci. Prosimy o kontakt na adres: coo.maan#gmail.com');
window.location = 'Contacts.html';
</script>
<?php
}
?>
If somebody could help me...
I know that i should use more css, but this is not the reason.
It looks like you have no way to submit your form.
Further, to add your checkbox data to your email message, you can use something like the following.
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
var_dump($_POST);
$message = '';
$message .= sprintf("Name: %s\n", isset($_POST['name']) ? $_POST['name'] : '');
$message .= sprintf("Foo wanted: %s\n", isset($_POST['foo']) ? 'Yes' : 'No');
$message .= sprintf("Bar wanted: %s\n", isset($_POST['bar']) ? 'Yes' : 'No');
var_dump($message);
}
?>
<form method="POST">
Your Name:<input type="text" name="name" /><br />
<input type="checkbox" name="foo" />You want Foo?<br />
<input type="checkbox" name="bar" />You want Bar?<br />
<input type="submit">
</form>
However please research 'email injection in php'.
You need to add the content to $body_message.
Change
$thenderese = $_POST['thenderese'];
if ($thenderese != 'Yes') {
$thenderese = 'No';
}
to
$thenderese = $_POST['thenderese'];
$body_message .= 'thenderese';
if ($thenderese != 'Yes') {
$body_message .= 'No';
}
else {
$body_message .= 'Yes';
}
$body_message .= '/n';
and continue for the rest of your if statements.

want to insert in attendence first time not update it

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

Multiple div tags in table for specific text box lengths

I have a table with several different <input type = 'text'>. Some should be 64 characters long, some 7 character, and some 4 characters. Luckily, they are all grouped together so I figured the best way to do this would be multiple div tags for each section. However, when I attempt to adjust the width in the CSS, none of the inputs change. What gives? I have an external CSS. The table code and the CSS code are below
On a side note, I am aware that 64px != 64 characters
EDIT: Fixed for working html code.
The table:
<?php
require_once('auth.php');
//Include database connection details
require_once('config.php');
?>
<html>
<head>
<title>Edit Profile</title>
<link rel = 'stylesheet' type = 'text/css' href = 'default.css' />
</head>
<body>
<div id = 'sideContainer'>
<div id = 'navMain'>
<?php include 'sidebar.html'; ?>
</div>
</div>
<div id = 'content'>
<?php
$memberID = $_SESSION['SESS_MEMBER_ID'];
$query = "SELECT * FROM memberData WHERE member_ID = '$memberID'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$vCode = $row['vCode'];
$keyID = $row['keyID'];
$mlYeild = $row['mlYeild'];
$cycleTime = $row['cycleTime'];
$veld = $row['veld'];
$scor = $row['scor'];
$pyro = $row['pyro'];
$plag = $row['plag'];
$omber = $row['omber'];
$kern = $row['kern'];
$jas = $row['jas'];
$hemo = $row['hemo'];
$gneiss = $row['gneiss'];
$ochre = $row['ochre'];
$spod = $row['spod'];
$crok = $row['crok'];
$bistot = $row['bistot'];
$ark = $row['ark'];
$merc = $row['merc'];
}
?>
<form id = 'editPlayerInfo' name = 'editPlayerInfo' method = 'post' action = 'editUser-exec.php'>
<table border = '0'>
<tr>
<td colspan = '2'><h2>API stuff</h2></td>
</tr>
<tr>
<td><h3>vCode</h3></td>
<td><div id = 'vCode'><input type = 'text' name = 'vCode' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
</tr>
<tr>
<td><h3>keyID</h3></td>
<td><div id = 'keyID'><input name = 'keyID' type = 'text' value = '<?php echo $keyID; ?>'></div>
</td>
</tr>
</table>
<HR>
<div id = 'refining'>
<table>
<tr>
<td colspan = '4'><h2>Mining Laser stuff</h2></td>
</tr>
<tr>
<td><h3>Mining Laser Yeild</h3></td>
<td><input name = 'mlYeild' type = 'text' class = 'textfield' id = 'mlYeild' value = '<?php echo $mlYeild; ?>'/></td>
</tr>
<tr>
<td><h3>Cycle Time</h3></td>
<td><input name = 'cycleTime' type = 'text' class = 'textfield' id = 'cycleTime' value = '<?php echo $cycleTime; ?>'/></td>
</tr>
</table>
<HR>
<table>
<tr>
<td colspan = '6'><h2>Yeild Specifics</h2></td>
</tr>
<td><h3>Veldspar Yeild</h3></td>
<td><input name = 'veldYeild' type = 'text' class = 'textfield' id = 'veldYeild' value = '<?php echo $veld; ?>'/></td>
<td><h3>Scordite Yeild</h3></td>
<td><input name = 'scorYeild' type = 'text' class = 'textfield' id = 'scorYeild' value = '<?php echo $scor; ?>'/></td>
<td><h3>Pyroxeres Yeild</h3></td>
<td><input name = 'pyroYeild' type = 'text' class = 'textfield' id = 'pyroYeild' value = '<?php echo $pyro; ?>'/></td>
</tr>
<tr>
<td><h3>Plagioclase Yeild</h3></td>
<td><input name = 'plagYeild' type = 'text' class = 'textfield' id = 'plagYeild' value = '<?php echo $plag; ?>'/></td>
<td><h3>Omber Yeild</h3></td>
<td><input name = 'omberYeild' type = 'text' class = 'textfield' id = 'omberYeild' value = '<?php echo $omber; ?>'/></td>
<td><h3>Kernite Yeild</h3></td>
<td><input name = 'kernYeild' type = 'text' class = 'textfield' id = 'kernYeild' value = '<?php echo $kern; ?>'/></td>
</tr>
<tr>
<td><h3>Jaspet Yeild</h3></td>
<td><input name = 'jasYeild' type = 'text' class = 'textfield' id = 'jasYeild' value = '<?php echo $jas; ?>'/></td>
<td><h3>Hemorphite Yeild</h3></td>
<td><input name = 'hemYeild' type = 'text' class = 'textfield' id = 'hemYeild' value = '<?php echo $hemo; ?>'/></td>
<td><h3>Gneiss Yeild</h3></td>
<td><input name = 'gneissYeild' type = 'text' class = 'textfield' id = 'gneissYeild' value = '<?php echo $gneiss; ?>'/></td>
</tr>
<tr>
<td><h3>Dark ochre Yeild</h3></td>
<td><input name = 'ochreYeild' type = 'text' class = 'textfield' id = 'ochreYeild' value = '<?php echo $ochre; ?>'/></td>
<td><h3>Spodumain Yeild</h3></td>
<td><input name = 'spodYield' type = 'text' class = 'textfield' id = 'spodYield' value = '<?php echo $spod; ?>'/></td>
<td><h3>Crokite Yeild</h3></td>
<td><input name = 'crokYeild' type = 'text' class = 'textfield' id = 'crokYeild' value = '<?php echo $crok; ?>'/></td>
</tr>
<tr>
<td><h3>Bistot Yeild</h3></td>
<td><input name = 'bisYeild' type = 'text' class = 'textfield' id = 'bisYeild' value = '<?php echo $bistot; ?>'/></td>
<td><h3>Arkonor Yeild</h3></td>
<td><input name = 'arkYeild' type = 'text' class = 'textfield' id = 'arkYeild' value = '<?php echo $ark; ?>'/></td>
<td><h3>Mercoxit Yeild</h3></td>
<td><input name = 'mercYeild' type = 'text' class = 'textfield' id = 'mercYeild' value = '<?php echo $merc; ?>'/></td>
</tr>
</table>
<table align = 'center'>
<tr>
<td><input type = 'submit' value = 'Make Changes'></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
The CSS
#sideContainer {float:left;}
#content {
float:left;
padding-left: 5px;
}
#content table {
border-spacing:10;
border-collapse:collapse;
}
#content h1 {
vertical-align:top;
height:40px; overflow:;
color: #99CC00;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
font: bold 18px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
#content h2 {
vertical-align:top;
height:40px; overflow:;
color: #336622;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
font: bold 24px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
#content h3 {
text-align:bottom;
height:30px; overflow:;
color: #99CC00;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
font: bold 18px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
#content th {
font-weight: bold;
text-align: left;
}
#content a {
color: #2D3954;
font-size: 11px;
}
#content a:hover {
color: #99CC00;
}
#userTable input{
vertical-align:center;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
background: #ccffaa;
}
#vCode input{
width: 10px;
}
#keyID input{
width:100px;
}
#refining input{
width:50px;
}
#sideTable {
float:left;
padding-left: 5px;
}
.err {
color: #FF9900;
}
#navMain {
margin-left:25px;
color:#c3c3c3;
font-family:Tahoma, Geneva, sans-serif;
}
#navMain h2{
font-family:Trebuchet MS1, Helvetica, sans-serif;
} /*Change font of the title*/
#navMain ul{
padding:0;
margin:0;
margin-left:25px;
font-size:15;
margin-right:20px;
} /*Reset the default padding/margin and set it as required*/
#navMain ul li a{
font-size:15;
text-decoration:none;
color:#c3c3c3;
} /*Change color of link text and remove underline*/
#navMain ul li a:hover{
color:#e0993e;
} /*Change color of hover text*
sidebar.html
<h2>Categories</h2>
<ul>
<li>Edit Personal Info</li>
<li>Sell to Corp</li>
<li>Fleet Log Parser</li>
<li>Theoretical Mining</li>
<li>Theoretical Refining</li>
<li>Send Corp Mail - N/A</li>
<li>Set Corp Rate</li>
<li>Update Skills</li>
<li>logout</li>
</ul>
You need to move your div's inside your td tags. Something like this :
<div id='content'>some content is here
<div id='userTable'>
<table>
<tr>
<th>table header</th>
</tr>
<tr>
<td>
<div id='chars64'>
<input type='text' value='1234567812345678123456781234567812345678123456781234567812345678'>
</div>
</td>
</tr>
<tr>
<td>
<div id='chars7'>
<input type='text' value='1234567'>
</div>
</td>
</tr>
<tr>
<td>
<div id='chars4'>
<input type='text' value='0.123'>
</div>
</td>
</tr>
</table>
Here is the jsfiddle for it : http://jsfiddle.net/TM5Mk/
you can also refer to these previous discussions :
div inside table
Placing a div inside a table cell
You do not have a valid HTML table.
You should have div elements inside td element and then style the inputs. It is not valid to add <div> before tr element.
Working Fiddle | | Updated Working Fiddle
<div id = 'content'>
some content is here
<div id = 'userTable'>
<table>
<tr>
<th>table header</th>
</tr>
<tr>
<td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
<td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
<td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
<td><div id = 'chars64'><input type = 'text' value = '1234567812345678123456781234567812345678123456781234567812345678'></div></td>
</tr>
<tr>
<td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
<td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
<td><div id = 'chars7'><input type = 'text' value = '1234567'</div</td>
</tr>
<tr>
<td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
<td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
<td><div id = 'chars4'><input type = 'text' value = '0.123'></div></td>
</tr>
</table>
</div>
</div>
I think that's because your HTML is wrong. You can put <table> elements in <div>. Just wrap the input in <div> .. not the entire <tr>. Here is:
<div id = "content">
some content is here
<div id = "userTable">
<table>
<tr>
<th>table header</th>
</tr>
<tr>
<td>
<div id = "chars64">
<input type = "text" value = "1234567812345678123456781234567812345678123456781234567812345678">
</div>
</td>
</tr>
<tr>
<td>
<div id = "chars7">
<input type = "text" value = "1234567">
</div>
</td>
</tr>
<tr>
<td>
<div id = "chars4">
<input type = "text" value = "0.123">
</div>
</td>
</tr>
</table>
</div>
</div>

Using MYSQL and dropdowns

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>";

Categories