How can I get the value of it from html to php? - php

How can I get the value of information from html to php? with the calculation of Interest = Loan Amount * 5% (or 10%), Total Loan Amount = Loan Amount + Interest, Monthly Dues = Total Loan Amount / Number of Terms (6, 12, 24). What should write in php?
<!doctype html>
<html lang= "en">
<head><title>Registration Form</title>
<style>
.Cn{
text-align:center;
color:#1e90ff;
font-family:Arial, Helvetica, sans-serif;
}
.add{
color:black;
font-family:Arial, Helvetica, sans-serif;
}
.h1{
text-align:center;
color:black;
font-family:Arial, Helvetica, sans-serif;
}
table, th, td {
border: 1px solid black;
align:center;
}
table.center{
margin-left:auto;
margin-right:auto;
}
table {
border-collapse: collapse;
}
</style>
</head>
<body>
<form action="LoanInformation.php" method="post">
<h2 class="Cn">Loan</h2>
<center class="add">blah City<br>
Mobile Number: 12345678900 <br> Telephone:(08)9999999
</center>
<hr style="Width:100%;color:#dc143c">
Borrower Information:<br>
Name:<input type"text" name="name"><br>
Address:<input type"text" name="address"><br>
Contact#:<input type"text" name="contact">
<h1 class="h1">Loan Amount</h1>
<div>
<table class="center">
<tr>
<th>Select Loan Amount</th>
</tr>
<tr>
<td><input type="radio" name='r1' value="Php 5,000">Php 5,000</td>
</tr>
<tr>
<td><input type="radio" name='r1' value="Php 10,000">Php 10,000</td>
</tr>
<tr>
<td><input type="radio" name='r1' value="Php 15,000">Php 15,000</td>
</tr>
<tr>
<td><input type="radio" name='r1' value="Php 20,000">Php 20,000</td>
</tr>
<td><input type="radio" name='r1' value="Php 25,000">Php 25,000</td>
</tr>
<tr>
<th>Terms of Payment</th>
</tr>
<tr><td><input type="radio" name="r2" value="6 months">6 mos</td></tr>
<tr><td><input type="radio" name="r2" value="12 months">12 mos</td></tr>
<td><input type="radio" name="r2" value="24 months">24 mos</td>
<tr> <th>Cooperative Officer</th></tr>
<tr><td><input type="checkbox" name="chckbx">Yes</td></tr>
</table>
</div>
<br>
<div class="button">
<center><input type="submit" value="Submit">
<input type="reset" value="Clear All">
</center>
</div>
</form>
</body>
</html>
here is the code i wrote in php but it's incomplete. some php is empty because i don't know what to code in there. in interest is loan amount multiply by 5%, the total amount is loan amount plus the interest and monthly dues is total loan amount divide by months in radio button choice.and if the "cooperative officer" checkbox is not selected the interest should be 10%.
<!doctype html>
<html lang= "en">
<head><title>Registration Form</title>
<style>
.Cn{
text-align:center;
color:#1e90ff;
font-family:Arial, Helvetica, sans-serif;
}
.add{
color:black;
font-family:Arial, Helvetica, sans-serif;
}
.h1{
text-align:center;
color:black;
font-family:Arial, Helvetica, sans-serif;
}
table, th, td {
border: 1px solid black;
align:center;
}
table.center{
margin-left:auto;
margin-right:auto;
}
table {
border-collapse: collapse;
}
</style>
</head>
<body>
<h2 class="Cn">Loan</h2>
<center class="add">blah City<br>
Mobile Number: 12345678900 <br> Telephone:(08)9999999
</center>
<hr style="Width:100%;color:#dc143c">
<h1 class="h1">Loan Information</h1>
<table class="center">
<tr><td>Date</td>
<td><?php echo date('F d, Y'); ?></td>
</tr>
<tr>
<td>Name</td>
<td><?php echo $_POST["name"];?></td>
</tr>
<tr>
<td>Address</td>
<td><?php echo $_POST["address"];?></td>
</tr>
<tr>
<td>Contact</td>
<td><?php echo $_POST["contact"]; ?></td>
</tr>
<tr>
<td>Amount</td>
<td><?php if(isset($_POST['r1'])){
$amount = $_POST['r1'];
echo $amount;
}
?></td>
</tr>
<tr>
<td>Terms of Payment</td>
<td><?php if(isset($_POST['r2'])){
$months = $_POST['r2'];
echo $months;
}
?></td>
</tr>
<tr>
<td>Interest (5%)</td>
<td><?php ?></td>
</tr>
<tr>
<td>Total Amount</td>
<td><?php ?>;</td>
</tr>
<tr>
<td>Monthly Dues</td>
<td><?php echo $_POST[""]?>;</td>
</tr>
</table>
<center>
<input type="submit" value="Submit"> <br>
<input type="submit" value ="back">
</center>
</body>
</html>

First of all, make the value of your radio buttons with the amount of the loan pure integers (5000, 10000, ...), do the same for the duration of the loan (6, 12, 24).
After you can calculate the values like this:
$interest = isset($_POST['chckbx']) ? 0.1 : 0.05; // 10% interest rate if checkbox is checked, else 5%
$interestValue = $_POST['r1'] * $interest;
$totalAmount = $_POST['r1'] + $interestValue;
$monthlyDue = $totalAmount / $_POST['r2'];
You can format the money values using number_format:
$moneyValue = 'Php ' . number_fomat($value, 2, '.', ',');

Related

I can't edit my mail text in the PHP mailer

I have set up a site and added a contact form into it. Php mailer work correctly but when the mail text arrives to me there is no empty between the letters. All of them is adjoining. I want to list titles one under to other mailer.php. The code is like this
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet ="utf-8";
$mail->Username = "sample";
$mail->Password = "sample";
$mail->SetFrom("sample#sample.com", "Baslik");
$mail->AddAddress("sample#sample.com");
$mail->Subject = "Siteden Gönderildi";
include("iletisim.html");
$mail->Body = $frmName= $_POST["frmName"].
$frmCity= $_POST["frmCity"] .
$adressatiri= $_POST["adressatiri"].
$adressatiri2= $_POST["adressatiri2"].
$email= $_POST["email"] .
$frmTelephone= $_POST["frmTelephone"] .
$frmPhoneType= $_POST["frmPhoneType"] .
$frmContactBy= $_POST["frmContactBy"] .
$frmBestTime= $_POST["frmBestTime"] .
$frmMessage= $_POST["frmMessage"];
if(!$mail->Send()){
echo "Mailer Error: ".$mail->ErrorInfo;
} else {
echo "Mesajınız Gonderilmistir";
}
?>
and contact.html file is like this. If you can help me i will be very happy. Because i didnt solve this problem throughout one
<!doctype html>
<html>
<head>
<link rel="Shortcut Icon" href="image/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<title>Sena DOĞAN Kişisel Web Sitesi</title>
<style type="text/css">
body, p, table, th, td, div {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
th {
background-color:#0080C0;
color:white;
font-weight:bold;
font-size:18px;
border: 1px solid #0080C0;
}
input.text, textarea {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
width: 99%;
}
.text:focus, textarea:focus {
background-color: #FFFACC;
border: 1px solid #000000;
}
#mydiv {
margin-left: auto ;
margin-right: auto ;
width: 500px;
text-align: left;
}
td.colone {
text-align: right;
vertical-align: top;
padding-top:6px;
width:20%;
}
td.coltwo {
color:red;
text-align: center;
vertical-align: top;
padding-top:9px;
}
td.colthree {
width:80%
}
table.border {
border: 1px solid #0080C0;
border-collapse: collapse;
}
</style>
<link href="banner.css" rel="stylesheet" type="text/css">
}
</head>
<body>
<div class="container"> <img src="image/Sena banner.png" width="999" height="258" alt="KTU"/>
<div id="navbar">
<ul style="">
<li style="">Ana Sayfa</li>
<li> Hakkında</li>
<li> Projeler</li>
<li>Deneyim</li>
<li> Galeri</li>
<li> İletişim</li>
<br>
<br>
<br></ul>
<br/>
<form method="POST" action="mailer.php" enctype="multipart/form-data">
<input type="hidden" value="samplecontactus.html" name="referer">
<table class="border" width="500" cellpadding="3" cellspacing="0">
<tr>
<th colspan="3" align="center">İletişim İçin Lütfen Aşağıdaki Kutuları Doldurun</th>
</tr>
<tr>
<td colspan="3"><div style="height:5px;"></div></td>
</tr>
<tr>
<td class="colone">Ad Soyad</td>
<td class="coltwo">*</td>
<td class="colthree"><input class="text" type="text" name="frmName" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Şehir</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="frmCity" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Adres</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="adressatiri" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Adres-2</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="adressatiri2" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">E-posta</td>
<td class="coltwo">*</td>
<td class="colthree"><input class="text" type="text" name="email" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Telefon</td>
<td class="coltwo"> </td>
<td class="colthree">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="200"><input class="text" type="text" name="frmTelephone" style="width:200px;"></td>
<td>
<select size="1" name="frmPhoneType">
<option value="Home">Ev</option>
<option value="Worx">İş</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="colone">Görüşme Şekli</td>
<td class="coltwo"> </td>
<td class="colthree">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="1">
<select size="1" name="frmContactBy">
<option value="Telefon">Telefon</option>
<option value="Email">E-Posta</option>
</select>
</td>
<td>
<select size="1" name="frmBestTime">
<option value="Morning">Gündüz</option>
<option value="Afternoon">Öğle</option>
<option value="Evening">Akşam</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="colone">Mesaj</td>
<td class="coltwo">*</td>
<td class="colthree"><textarea class="text" name="frmMessage" style="width:98%;height:100px;"></textarea></td>
</tr>
<tr>
<td class="colone" colspan="2"> </td>
<td class="colthree"><input type="submit" value="Gönder" name="submit"><input type="reset" value="Reset" name="reset"></td>
</tr>
<tr>
<td colspan="3"><div style="height:5px;"></div></td>
</tr>
</table>
</form>
</div>
<h2><span style="color: #ED0F13"><center>
</center>
</span></h2>
<blockquote>
<p> </p>
<p><span class="copyright" style="text-align: center"><span class="copyright"><center class="copyright">Copyright © 2018 DOĞAN Web Tasarım™</center><span class="copyright"><span class="copyright"></span></span>
</center>
</span></span></p>
</blockquote>
<p><span class="imagefloatleft">
<article id="123"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span><span class="imagefloatleft">
<article id="text"> </article>
</span><span class="imagefloatleft">
<article id="text"></article>
</span></p>
</div>
</body>
</html>
It's because HTML collapses white space. The easiest way to fix this is to convert real line breaks into HTML break tags in your message body:
$mail->Body = nl2br($mail->Body);
As a result of my researches I have found a solution like this
<a><span style='font-weight: bold;'>İsim:</span> ".$_POST["frmName"]."</a><br>
<a><span style='font-weight: bold;'>Şehir:</span> ".$_POST["frmCity"]."</a><br>
<a><span style='font-weight: bold;'>Adres 1:</span> ".$_POST["adressatiri"]."</a><br>
<a><span style='font-weight: bold;'>Adres 2:</span> ".$_POST["adressatiri2"]."</a><br>
<a><span style='font-weight: bold;'>E-posta:</span> ".$_POST["email"]."</a><br>
<a><span style='font-weight: bold;'>Telefon:</span> ".$_POST["frmTelephone"]."</a><br>
<a><span style='font-weight: bold;'>Telefon Tipi:</span> ".$_POST["frmPhoneType"]."</a><br>
<a><span style='font-weight: bold;'>Görüşme Şekli:</span> ".$_POST["frmContactBy"]."</a><br>
<a><span style='font-weight: bold;'>En uygun zaman:</span> ".$_POST["frmBestTime"]."</a><br>
<a><span style='font-weight: bold;'>Mesaj:</span> ".$_POST["frmMessage"]."</a>

data not get in select section more times

when i click update button without any change in editing form..the fields of product category and product brand become empty... and in database the record at that place also become empty.please help me what i should do for this problem.
<?php
include("include/db.php");
if(isset($_GET['edit_pro'])){
$get_id=$_GET['edit_pro'];
$get_pro="select * from products where product_id='$get_id'";
$run_pro=mysqli_query($db, $get_pro);
$row_pro=mysqli_fetch_array($run_pro);
$pro_id=$row_pro['product_id'];
$pro_title=$row_pro['product_title'];
$pro_image1=$row_pro['product_img1'];
$pro_image2=$row_pro['product_img2'];
$pro_image3=$row_pro['product_img3'];
$pro_price=$row_pro['product_price'];
$pro_desc=$row_pro['product_desc'];
$pro_keywords=$row_pro['product_keywords'];
$pro_cat=$row_pro['cat_id'];
$pro_brand=$row_pro['brand_id'];
$get_cat="select * from categories where cat_id='$pro_cat'";
$run_cat=mysqli_query($db,$get_cat);
$row_cat=mysqli_fetch_array($run_cat);
$cat_title=$row_cat['cat_title'];
$get_brand="select * from brands where brand_id='$pro_brand'";
$run_brand=mysqli_query($db,$get_brand);
$row_brand=mysqli_fetch_array($run_brand);
$brand_title=$row_brand['brand_title'];
}
?>
<!DOCTYPE>
<html>
<head><title>update product</title>
<!--text editor taken from tinymce.com-->
<!--<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>-->
<link rel="stylesheet" href="styles/stylesheet.css" media="all">
</head>
<body>
<form method="post" action="" enctype="multipart/form-data" align="center">
<center><table width="700" align="center">
<tr align="center" style="background-color:transparent;">
<td colspan="2"><h2>edit product</h2></td>
</tr>
<tr class="button_row">
<td align="right"><b>product title</b></td>
<td><input type="text" name="product_title" value="<?php echo $pro_title; ?>" size="40" placeholder="enter title" style="background-color:transparent; color:gray; border:1px solid black;"></td>
</tr>
<tr>
<td align="right"><b>product category</b></td>
<td>
<select name="product_cat" style="background-color:transparent; color:gray; border:1px solid black; opacity:0.6;">
<option value=""><?php echo $cat_title; ?></option>
<?php
$get_cats="select * from categories";
$run_cats=mysqli_query($db,$get_cats);
while($row_cats=mysqli_fetch_array($run_cats)){
$cat_id=$row_cats['cat_id'];
$cat_title=$row_cats['cat_title'];
echo "<option value='$cat_id'>$cat_title</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td align="right"><b>product brand</b></td>
<td>
<select name="product_brand" style="background-color:transparent; color:gray; border:1px solid black; opacity:0.6;">
<option value=""><?php echo $brand_title; ?></option>
<?php
$get_brands="select * from brands";
$run_brands=mysqli_query($db,$get_brands);
while($row_brands=mysqli_fetch_array($run_brands)){
$brand_id=$row_brands['brand_id'];
$brand_title=$row_brands['brand_title'];
echo "<option value='$brand_id'>$brand_title</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td align="right"><b>product image 1</b></td>
<td><input type="file" name="product_img1" style="background-color:transparent; color:gray; opacity:0.7;"><img src="product_images/<?php echo $pro_image1; ?>" width="60" height="40"></td>
</tr>
<tr>
<td align="right"><b>product image 2</b></td>
<td><input type="file" name="product_img2" style="background-color:transparent; color:gray; opacity:0.7;"><img src="product_images/<?php echo $pro_image2; ?>" width="60" height="40"></td>
</tr>
<tr>
<td align="right"><b>product image 3</b></td>
<td><input type="file" name="product_img3" style="background-color:transparent; color:gray; opacity:0.7;"><img src="product_images/<?php echo $pro_image3; ?>" width="60" height="40"></td>
</tr>
<tr>
<td align="right"><b>product price</b></td>
<td><input type="text" name="product_price" value="<?php echo $pro_price; ?>" placeholder="enter price" style="background-color:transparent; color:gray; border:1px solid black;"></td>
</tr>
<tr>
<td align="right"><b>product description</b></td>
<td><textarea name="product_desc" cols="30" rows="1" placeholder="enter description" style="background-color:transparent; color:gray; border:1px solid black; outline: none;"><?php echo $pro_desc; ?></textarea></td>
</tr>
<tr>
<td align="right"><b>product keywords</b></td>
<td><input type="text" name="product_keywords" size="40" value="<?php echo $pro_keywords; ?>" placeholder="enter keywords" style="background-color:transparent; color:gray; border:1px solid black;"></td>
</tr>
<tr align="center" class="button_row">
<td colspan="2"><input type="submit" name="update" value="update product" style="background-color:transparent; width:120px; height:25px; font-size:15px; color:black; padding-bottom:10px; border:2px solid gray; text-align:center;"></td>
</tr>
</table></center>
</form>
</body>
</html>
<?php
if(isset($_POST['update'])){
$update_id=$pro_id;
$product_title=$_POST['product_title'];
$product_cat=$_POST['product_cat'];
$product_brand=$_POST['product_brand'];
$product_price=$_POST['product_price'];
$product_desc=$_POST['product_desc'];
$status='on';
$product_keywords=$_POST['product_keywords'];
//image names
$product_img1 = $_FILES['product_img1']['name'];
$product_img2 = $_FILES['product_img2']['name'];
$product_img3 = $_FILES['product_img3']['name'];
//image temo names
$temp_name1 = $_FILES['product_img1']['tmp_name'];
$temp_name2 = $_FILES['product_img2']['tmp_name'];
$temp_name3 = $_FILES['product_img3']['tmp_name'];
move_uploaded_file($temp_name1,"product_images/$product_img1");
move_uploaded_file($temp_name2,"product_images/$product_img2");
move_uploaded_file($temp_name3,"product_images/$product_img3");
if(!empty($_FILES['product_img1']['name']) AND
!empty($_FILES['product_img2']['name']) AND
!empty($_FILES['product_img3']['name']))
{
$update_product="update products set cat_id='$product_cat',
brand_id='$product_brand',
product_title='$product_title',
product_price='$product_price',
product_img1='$product_img1',
product_img2='$product_img2',
product_img3='$product_img3',
product_desc='$product_desc',
product_keywords='$product_keywords'
where product_id='$update_id'";
} else {
$update_product="update products set cat_id='$product_cat',
brand_id='$product_brand',
product_title='$product_title',
product_price='$product_price',
product_desc='$product_desc',
product_keywords='$product_keywords'
where product_id='$update_id'";
}
$run_update=mysqli_query($db, $update_product);
if($run_update){
echo "<script>alert('product has been updated')</script>";
echo "<script>window.open('index.php?view_products','_self') </script>";
}
}
?>

HTML select box doesnt highlight last option

My code can be found here: http://macrorevolution.com/calculators/tdee/
When I put my mouse over the last <option></option> it does not highlight as opposed to the rest of the options. I've tried adding more options and each time it is the last option that does not highlight. How can I fix this?
<?php
$answer = "";
$agev = "";
$feetv = "";
$inchesv = "";
$weightv = "";
$sex = "";
$activelevel = "";
if(isset($_POST['agev']) && isset($_POST['feetv']) && isset($_POST['inchesv']) && isset($_POST['weightv']) && isset($_POST['sex'])) {
//&& isset($_POST['activelevel'])
$agev = $_POST['agev'];
$feetv = $_POST['feetv'];
$inchesv = $_POST['inchesv'];
$weightv = $_POST['weightv'];
$sex = $_POST['sex'];
$activelevel = $_POST['activelevel'];
$totalheightv = $inchesv + ($feetv*12);
$heightcm = $totalheightv*2.54;
$weightkg = $weightv/2.2;
if($activelevel=='1v') $activelevel=1.2;
else if($activelevel=='2v') $activelevel=1.375;
else if($activelevel=='3v') $activelevel=1.55;
else if($activelevel=='4v') $activelevel=1.725;
else if($activelevel=='5v') $activelevel=1.9;
else echo "error";
//echo $activelevel;
if($sex=='male') $answer = $activelevel * (66.47 + (13.75*$weightkg) + (5*$heightcm) - (6.75*$agev));
if($sex=='female') $answer = $activelevel * (665.09 + (9.56*$weightkg) + (1.84*$heightcm) - (4.67*$agev));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<title>Total Daily Energy Expenditure</title>
<style type="text/css">
.bold {
font-weight:bold;
}
table {
font-size:14px;
font-family: 'PT Sans', sans-serif;
background-color:#FFFFFF;
}
tr.spaceUnder > td
{
padding:0em 1em 1em 0em;
}
p.ss {
font-size:30px;
text-align:center
}
input {
margin-right:5px;
margin-left:5px;
}
.bp
{
border: 1px solid #000000;
text-align:center;
}
</style>
</head>
<body>
<div class="box pt20">
<p class="ss">MacroRevolution TDEE Calculator</p><br>
<table width='80%' style="margin: 0 auto;">
<tr class="spaceUnder">
<td colspan="4">
TDEE = Total Daily Energy Expenditure. TDEE is the amount calories your body burns in a 24 hour period which includes eating, sleeping, excercising, and working.
</td>
</tr>
</table>
<form method='post' action=''>
<table width='80%' style="margin: 0 auto;">
<tr class="spaceUnder">
<td>Age:</td>
<td><input type='text' name='agev' value="<?php echo $agev; ?>"/>Years</td>
</tr>
<tr class="spaceUnder">
<td>Height:</td>
<td align="justify"><input type='text' name='feetv' value="<?php echo $feetv; ?>"/>Ft
<input type='text' name='inchesv' value="<?php echo $inchesv; ?>"/>In</td>
</tr>
<tr class="spaceUnder">
<td>Weight:</td>
<td align="left"><input type='text' name='weightv' value="<?php echo $weightv; ?>"/>lbs</td>
</tr>
<tr class="spaceUnder">
<td colspan="2"><input type='radio' name='sex' value='male'>Male
<input type='radio' name='sex' value='female'>Female</td>
</tr>
<tr class="spaceUnder">
<td colspan="2">
<select name="activelevel">
<option name='activelevel' value='1v'>Little or no Excercise / Desk job</option>
<option name='activelevel' value='2v'>Light exercise / Workout 1-3 days/week</option>
<option name='activelevel' value='3v'>Moderate exercise / Workout 3-5 days/week</option>
<option name='activelevel' value='4v'>Heavy exercise / Workout 6-7 days/week</option>
<option name='activelevel' value='5v'>Very heavy exercise / Physical job / Workout 2 times a day</option>
</select>
</td>
</tr>
<tr class="spaceUnder">
<td colspan="2"><input type='submit' class="button highlight small" value='Calculate'/></td>
</tr>
<tr class="spaceUnder">
<td colspan="2">Your TDEE is <input type='text' style="width: 50px; font-weight:bold;" value='<?php echo round($answer,0); ?>' /><strong>k/cal per day</strong> </td>
</tr>
</table>
</form>
<table width='80%' style="margin: 0 auto;">
<td colspan="4">
TDEE = BMR x Activity Level <br>
Where the formula for BMR(Harris-Benedict formula) is <br><br>
Men: BMR=66.47+ (13.75 x W) + (5.0 x H) - (6.75 x A) <br>
Women: BMR=665.09 + (9.56 x W) + (1.84 x H) - (4.67 x A) <br><br>
W = Weight in kilograms (lbs/2.2)<br>
H = Height in centimeters (inches x 2.54)<br>
A = Age in years <br><br><br>
<table width='500px' style="border: 1px solid;" class="bp">
<tr class="bp">
<th class="bp">Amount of Activity</th>
<th class="bp">Description</th>
<th class="bp">TDEE Activity Level</th>
</tr>
<tr class="bp">
<td class="bp">Sedentary</td>
<td class="bp">Little or no Excercise / Desk job</td>
<td class="bp">1.2</td>
</tr>
<tr class="bp">
<td class="bp">Lightly Active</td>
<td class="bp">Light exercise / Workout 1-3 days/week</td>
<td class="bp">1.375</td>
</tr>
<tr class="bp">
<td class="bp">Moderately Active</td>
<td class="bp">Moderate exercise / Workout 3-5 days/week</td>
<td class="bp">1.55</td>
</tr>
<tr class="bp">
<td class="bp">Very Active</td>
<td class="bp">Heavy exercise / Workout 6-7 days/week</td>
<td class="bp">1.725</td>
</tr>
<tr class="bp">
<td class="bp">Extremely Active</td>
<td class="bp">Very heavy exercise / Physical job / Workout 2 times a day</td>
<td class="bp">1.9</td>
</tr>
</table>
<br><br><br>
</tr>
</table>
</div>
</body>
</html>
Update This Chrome bug ticket, similar to the bug ticket listed below except that this ticket is specific to Chrome 32.0.1700.76
I am assuming you are using Chrome?
My coworker and I ran into this issue yesterday on every page we had drop-downs.
There happens to be a chrome bug describing the exact same issue. This bug ticket states a different version of chrome in the head of the ticket, but if you read the comments they note it also affects other versions of Chrome. forum post I read happened to be the same as my browser/OS (mine's 64-bit)
Chrome Version: 32.0.1700.76 m
Operating System: Windows 7
To verify try the following steps in your chrome browser (steps found in bug ticket)
What steps will reproduce the problem?
Launch Chrome and open "chrome://settings"
Click on any dropdown arrow to open the dropdown list
Mouse hover on all the dropdown items and observe
I don't think the issue is your code, it's Chrome. So there isn't anything you can do at this time.
Everything said, even though it doesn't highlight, it should still be clickable.

update query not work

This is the full code of the page which i am using to update data.I Tried many time but it still not updating values in database..also tried to echo but still not updating
<?php
session_start();
include '../func-tion/func.php';
if(isset($_SESSION['m_uname']) && isset($_SESSION['m_pass']))
{
?>
<?php
if(isset($_POST['subup']))
{
$SQL="update appid set android_appid='".$_POST['and_a']."' , iphone_appid='".$_POST['iph_a']."' , ipad_appid='".$_POST['ipa_a']."' where u_name='".$_GET['name']."'";
echo $SQL;
}
?>
<?php
$main_qry=mysql_query("select * from users where u_name='".$_GET['name']."'");
$main_fetch=mysql_fetch_assoc($main_qry);
?>
<center><h2 class="art-postheader">Edit details of <b></b></h2></center><br/><br/>
<table align="center">
<tr align="center">
<td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Username:<br>
<input type="text" name="u_name" style="width: 300px;" value="<?php echo $main_fetch['u_name']?>"></td>
</tr>
<tr align="center">
<td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Email:<br>
<input type="text" name="u_email" style="width: 300px;" value="<?php echo $main_fetch['u_email']?>"></td>
</tr><?php
$main_qrys=mysql_query("select * from appid where u_name='".$_GET['name']."'");
$row=mysql_fetch_assoc($main_qrys);
?> <form name="user" method="post" action="users_edit.php" onSubmit="return valid();">
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Android Appid:<br>
<input type="text" name="and_a" style="width: 300px;" value="<?php echo $row['android_appid']?>"></td>
</tr>
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone Appid:<br>
<input type="text" name="iph_a" style="width: 300px;" value="<?php echo $row['iphone_appid']?>"></td>
</tr>
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone(ipad) Appid:<br>
<input type="text" name="ipa_a" style="width: 300px;" value="<?php echo $row['ipad_appid']?>"></td>
</tr>
<tr align="center">
<td style="height: 28px;">
<button name="subup" type="submit">Edit</button>
</td>
</tr>
</form>
</table>
</div>
</div>
</div>
</div>
</div>
</body></html>
<?php
}
else
{
header("Location:notserver.php?l=fake");
}
?>
if anyone know..Please help me i will be very thankfull to him
Use the query:
UPDATE appid
set android_appid='$android_appid', iphone_appid='$iphone_appid', ipad_appid='$ipad_appid'
where u_name IN (select u_name from users where u_id = $_GET[id])
I wonder why you're using $_GET['id'] rather than $_POST['id'] like the other parameters in your script. Make sure that's correct. And you should check for errors from mysql_query(); if it returns false, print mysql_error() to see the reason.

Grab multidimensional array value in to table using foreach loop

This is my code; I will tell you the issue then.
<?php
//checking for perfect loging
session_start();
$user_name = $_SESSION['username'];
$user_pass = $_SESSION['password'];
require ("connection.php");
if ( $user_name == '' ) {
header('location:home.php');
exit();
}
/////////////////////////////////////
?>
<?php
//collecting posted variables by pressing addanother button
if(isset($_POST['adnother'])) {
$date = $_POST['date'];
$billnmbr = $_POST['billnmbr'];
$itemcode = $_POST['itemcode'];
$itemname = $_POST['itemname'];
$exdate = $_POST['exdate'];
$eachprice = $_POST['eachprice'];
$itmtotal = $_POST['itmtotal'];
$wasFound=false;
$i=0;
// check for >>>>>>>>>>> if the session bill_array array is not set or cart array is empty <<<<<<<<<<<<<<<
if(!isset($_SESSION["bill_array"]) || count($_SESSION["bill_array"]) < 1 ) {
// Run if the bill_array is empty or not set
$_SESSION["bill_array"]= array(1 => array("date"=> $date, "billnmbr"=> $billnmbr, "itemcode"=> $itemcode, "itemname"=> $itemname, "exdate"=> $exdate, "eachprice"=> $eachprice, "itmtotal"=> $itmtotal));
} else {
// Run if the bill has at least one item in it
foreach($_SESSION["bill_array"] as $each_item) {
$i++;
while(list($key,$value)=each($each_item)){
if($key=="itemcode" && $value == $itemcode){
// That item is in cart already so push a error message in to screen
$wasFound = true;
?>
<script type="text/javascript">
var error = "<?= $wasFound ?>";
if(error == "true") {
alert("You trying to add same item twice")
}
</script>
<?php
}//close if condition
}//close while loop
}//close foreach loop
//if the next item is not in the bill and then add it to the bill_array
if($wasFound==false){
array_push($_SESSION["bill_array"],array("date"=> $date, "billnmbr"=> $billnmbr, "itemcode"=> $itemcode, "itemname"=> $itemname, "exdate"=> $exdate, "eachprice"=> $eachprice, "itmtotal"=> $itmtotal));
}//clos if condition
}//close else statment
}//close ifisset
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Front-end Billing</title>
<link href="main.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
.mainheder {
font-size: 36px;
font-weight: bolder;
color: #00C;
text-align: center;
}
#headertopic {
position:absolute;
left:304px;
top:1px;
width:395px;
height:44px;
z-index:1;
background-color: #999900;
}
#mainmenue {
position:absolute;
left:208px;
top:78px;
width:614px;
height:48px;
z-index:10000;
}
#dateandtime {
position:absolute;
left:790px;
top:251px;
width:208px;
height:82px;
z-index:1;
}
#redcross {
position:absolute;
left:377px;
top:321px;
width:247px;
height:239px;
z-index:0;
}
#usrlogin {
position:absolute;
left:4px;
top:216px;
width:265px;
height:184px;
z-index:1;
}
#address {
position:absolute;
left:2px;
top:462px;
width:204px;
height:155px;
z-index:2;
}
#logdas {
position:absolute;
left:10px;
top:92px;
width:197px;
height:58px;
z-index:1;
}
.logdas {
font-weight: bold;
color: #00F;
}
#pagetheam {
position:absolute;
left:332px;
top:49px;
width:341px;
height:24px;
z-index:1;
text-align: center;
font-size: 18px;
font-weight: bolder;
color: #0CF;
text-decoration: underline;
}
#billingitems {
position:absolute;
left:11px;
top:186px;
width:489px;
height:293px;
z-index:1;
}
#printlayout {
position:absolute;
left:531px;
top:186px;
width:211px;
height:322px;
z-index:1;
text-align: center;
}
.printlayoutshopname {
font-size: 14px;
font-weight: bold;
color: #000;
}
.billaddrs {
font-size: 10px;
}
.bilnmbr {
font-size: 10px;
font-weight: bold;
text-align: left;
}
</style></head>
<body>
<div id="wrap">
<div id="headertopic" class="mainheder">Accoutnig for Phamacy</div>
<p> </p>
<p> </p>
<div id="mainmenue"> <?php // include 'index.html' ;?> </div>
<div id="logdas"><p class="logdas">Logged in as : <?php echo $user_name; ?></p>
<p class="logdas">Date : <?php echo date("Y-m-d") ?></p>
</div>
<div id="pagetheam">Front-end Billing </div>
<div id="billingitems">
<form id="form1" name="form1" method="post" action="biling.php">
<?php $data = mysql_query("SELECT * FROM billnumber ") ;
$info = mysql_fetch_array( $data );
$oldnumber = $info['bill_number'];
$oldnumber= $oldnumber + 1;
$Transaction_number = "PM". $oldnumber ;
?>
<table width="490" height="282" border="0">
<tr>
<td width="160"><input type="hidden" name="date" id="date" value=" <?php echo date("Y-m-d") ?> " /><?php echo date("Y-m-d") ?></td>
<td width="47"> </td>
<td width="69"> </td>
</tr>
<tr>
<td width="206">Bill Number</td>
<td width="160"><input type="hidden" name="billnmbr" id="billnmbr" value="<?php echo $Transaction_number; ?>" /><?php echo $Transaction_number; ?></td>
<td width="47"> </td>
<td width="69"> </td>
</tr>
<tr>
<td>Item Code</td>
<td><input type="text" name="itemcode" id="itemcode" tabindex="1" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Item Name</td>
<td><input type="text" name="itemname" id="itemname" tabindex="2" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Expier Date</td>
<td><input type="text" name="exdate" id="exdate" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Item Price</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Each :
<input type="text" name="eachprice" id="eachprice" /></td>
<td>Total :
<input type="text" name="itmtotal" id="itmtotal" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="adnother" id="adnother" value="add another item" tabindex="5" /></td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
<td> </td>
</tr>
</table>
</form>
</div>
<div id="printlayout">
<p><span class="printlayoutshopname">Yasitha Pharacy<br />
</span><span class="billaddrs">22,Colombathanthiri Mawatha, Ethulkotte, Kotte.</span></p>
<table width="211" border="0">
<tr>
<td width="103"><span class="bilnmbr">Bill No: <?php echo $Transaction_number; ?></span></td>
<td colspan="2" class="bilnmbr">Date: <?php echo date("Y-m-d") ?></td>
</tr>
<?php
if(isset($_POST['adnother'])) {
//taking items in the bill to variables if the bill_array is not empty.
$cartOutput="";
if(!isset($_SESSION["bill_array"]) || count($_SESSION["bill_array"]) < 1 ) {
$cartOutput = "<h2 align='center'> Bill is still empty </hd>";
}
else {
$i = 0;
foreach ($_SESSION["bill_array"]as $each_item ): ?>
<tr>
<td class="bilnmbr">Item code: </td>
<td colspan="2" class="bilnmbr"><?php echo $each_item['itemcode']; ?></td>
</tr>
<tr>
<td colspan="3" class="bilnmbr">Item Name:</td>
</tr>
<tr>
<td colspan="3" class="bilnmbr"><?php echo $each_item['itemname']; ?></td>
</tr>
<tr class="bilnmbr">
<td>Each</td>
<td width="98">Qty</td>
<td width="98">Total</td>
</tr>
<tr class="bilnmbr">
<td><?php echo $each_item['eachprice']; ?></td>
<td>20</td>
<td><?php echo $each_item['itmtotal']; ?></td>
</tr>
</table>
<?php endforeach; ?>
<?php
}
}
////////////////////////////////////////
?>
<p>
</p>
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php //closing div for wrapper?>
</div>
</body>
</html>
I used two dimensional array for insert item details to a session array, after inserting a item I want its details to be displayed in a separate table (right hand side) there is no problem with one item, when I add a item it is viewing in the perfect place, but when I add the second item it is going under that table without creating new row. What is the wrong with what I had done?
I found my error
i ended my foreach loop like this
</tr>
</table>
<?php endforeach;
}
}
////////////////////////////////////////
?>
but now i corrected to this way
</tr>
<?php endforeach;
}
}
////////////////////////////////////////
?>
</table>
now it's all ok.... thank you guys for wasting your time for my silly mistake... sorry.... :(

Categories