HTML select box doesnt highlight last option - php

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.

Related

How can I get the value of it from html to 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, '.', ',');

get individual child value from parent tag using onclick method

I want to get individual table id value with the individual button click. and I got the table id value but it shows all table id value's like (1234... 10).
How to get the individual table value (like clicking the 3rd button -> get 3rd table id only).
I am using both PHP and HTML code together.
This is my code.
<table>
<tr>
<td><b>S.No</b></td>
<td><b>User Name</b></td>
<td><b>Post Title</b></td>
<td><b>Post Date</b></td>
</tr>
<?php
require_once('databaseconnection.php');
$query = "SELECT * FROM `userpost`";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
?>
<tr>
<td style="width: 5%;" id="td_id" value="<?php echo " {$row[ 'postid']} "; ?>">
<?php echo "{$row['postid']}"; ?>
</td>
<td style="width: 15%;" id="td_user">
<?php echo "{$row['postuser']}"; ?>
</td>
<td style="width: 65%;" id="td_title">
<?php echo "{$row['posttitle']}"; ?>
</td>
<td style="width: 10%;">
<?php echo "{$row['postdate']}"; ?>
</td>
<td style="width: 5%;"><input id="getpostid" type="submit" value="view" onclick="actiongetpostid();"></input>
</td>
</tr>
<?php
}
?>
</table>
<script type="text/javascript">
function actiongetpostid() {
var tdid = $('tr').children('#td_id').text();
alert(tdid);
}
</script>
HTML code:
This table will create dynamically.
<tr>
<td style="width: 5%;" id="td_id" value="1">1</td>
<td style="width: 15%;" id="td_user">rose</td>
<td style="width: 65%;" id="td_title">YII2 framwork for PHP</td>
<td style="width: 10%;">2016-02-12</td>
<td style="width: 5%;"><input id="getpostid" type="submit" value="view" onclick="actiongetpostid();"></input>
</td>
</tr>
<tr>
<td style="width: 5%;" id="td_id" value="2">2</td>
<td style="width: 15%;" id="td_user">rose</td>
<td style="width: 65%;" id="td_title">Angular JS</td>
<td style="width: 10%;">2016-02-12</td>
<td style="width: 5%;"><input id="getpostid" type="submit" value="view" onclick="actiongetpostid();"></input>
</td>
</tr>
<tr>
<td style="width: 5%;" id="td_id" value="3">3</td>
<td style="width: 15%;" id="td_user">murali</td>
<td style="width: 65%;" id="td_title">EXT JS</td>
<td style="width: 10%;">2016-02-12</td>
<td style="width: 5%;"><input id="getpostid" type="submit" value="view" onclick="actiongetpostid();"></input>
</td>
</tr>
I am using this code within "while" loop so how to solve this issue. Please help me.
Firstly, I'm not sure why you are using <input> tags if you are just wanting to display the data. Use <button> tags instead.
On this note I would change your button td to something like:
<td style="width: 5%;"><button class="getpostid">View</button>
Note the use of class="getpostid". The use of id would only apply to the first element with getpostid as IDs can only be used once.
Then using jQuery:
$(document).ready(function(){
$('.getpostid').click(function(){
var tdid = $(this).parents('tr').find('#td_id').text();
alert(tdid);
});
});
Note the use of parents() instead of parent(). The latter can only go up one level in the DOM tree. Whereas the step needed is 2 levels.
Here is a JSFiddle with a working example.

Print Report only 6 data for 1 page

i create a report. i try print preview this report.
but i want show 6 data/page page size a4 (landscape).
i already try loop 24 data. and try print preview in google chrome
there 1 data must be down to page 2
see my picture
[![enter image description here][1]][1]
then i check page 2 already same.
this page 2
[![enter image description here][2]][2]
How to fix this, i want report show only 6 data/page
this is my full code, you can try in localhost.
<style>
#caption
{
color:white;
font-weight:bold;
text-align:center;
background-color: #4CAF50;
}
table
{
border-collapse: collapse;
}
th, td
{
padding: 0px;
font-family:arial;
font-size:13px
}
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
}
</style>
<table align="center" width="100%" border="1">
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php
$x = 1;
while($x <= 24)
{
?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Spain</td>
<td align="center">01 February 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php
$x++;
}
?>
</table>
In this situation, you could create a separate table per page with only 6 rows. Only display the "Data Pendaftar" on the first page, add class="break" to every table except the table on the last page and add a CSS rule table.break{page-break-after:always}. I added a <br /> after each table, so it looks good in the browser before it prints. This will always print 6 rows per page, even when you're accidentally in portrait mode...
<style>
#caption{color:white;font-weight:bold;text-align:center;background-color:#4CAF50}
table{border-collapse:collapse}
th, td{padding: 0px;font-family:arial;font-size:13px}
tr:nth-child(even){background-color:#f2f2f2}
th{background-color:#4CAF50;color:white}
table.break{page-break-after:always}
</style>
<?php $i = 1; while ($i <= 4) { ?>
<table align="center" width="100%" border="1"<?php if ($i < 4) { ?> class="break" <? } ?>>
<?php if ($i == 1) { ?>
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php } $x = 1; while ($x <= 6) { ?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Span</td>
<td align="center">01 Feb 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">021000000 | 0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php $x++; } ?>
</table>
<br />
<?php $i++; } ?>

Php not working with SQL database and inserting values

Hi if you go to http://www.deakin.edu.au/~jrhaywar/SIT104/Contact.php you will find the webpage workings (or not working in this case). What i wish for the program to do is show the form if there is not post action however if there is a post action to replace the form entries with the details of the forms. As Well as add the details to the SQL Database. However it now just repeats the tables and forms multiple times. Could someone look at this quickly for me and try to help fix the problem?
Cheers
Jesse,
Here's the code:
<!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>Assignment 1 - SIT 104 - 214151511</title>
<!--This is where the Classes and Division Styles are setup for recall later in the code-->
<style type="text/css">
#Wrapper{
Background:url(images/Crests.png);
background-size:26%;
background-position:top 6px;
height:100%;
}
#NavBar{
Height:26%;
Border:groove Gold 6px;
}
#Body{
Height:76%;
border:groove Gold 6px;
text-align:center;
}
#Footer{
Height:26%;
background:#999;
Border:groove gold 6px;
}
</style>
</head>
<body>
<!-- This is the php to setup the connection to the oracle database needed to record information and to display reciept -->
<?php
/* Set oracle user login and password info */
$dbuser = "jrhaywar"; /* your deakin login */
$dbpass = "haybreaker"; /* your oracle access password */
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);
if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}
/* build sql statement using form data */
$query = "SELECT * FROM sit104Items";
if(isset($_POST['Submit'])){
$name = $POST_['Name'];
$phone = $POST_['Phone'];
$email = $POST_['Email'];
$reason = $POST_['Reason'];
$message = $POST_['Message'];
$insert = $insert = "INSERT INTO ContactUs VALUES ('$name','$phone','$email','$reason','$message')";
$Insert = OCIParse($connect, $insert);
}
/* check the sql statement for errors and if errors report them */
$stmt = OCIParse($connect, $query);
//echo "SQL: $query<br>";
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);
?>
<!--This is the beggining of the code that will be shown in the browser Starting with the wrapper and Navigation bar and then continuing with the "body" division and ended by the footer-->
<div id="Wrapper">
<div id="NavBar">
<table style="width:100%" height="10%" bgcolor="#CCFF00">
<tr>
<td width="26%" align="center" ><a link href="ass1.htm"><b>Home Page</b></a></td>
<td width="26%" align="center"><a link href="Items.php"><b>Items</b></a></td>
<td width="26%" align="center" ><a link href="FAQ.html"><b>FAQ/HELP</b></a></td>
<td width="26%" align="center" ><a link href="Contact.html"><b>Contact Us</b></a></td>
</tr>
</table>
</div>
<div id="Body">
<font size="6" face="Serpentine Bold" color="lime" ><b>
Welcome to the Order Page, please order what you wish!</b>
<hr/>
</font>
<?php
while(OCIFetch($stmt)){
/*Calculate what to do and show if Post is found*/
if(isset($_POST['Submit'])){
echo('<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
</tr>
<tr>
<td width="6%" >Name:</td>
<td width="46%" >');
$fg1 = OCIResult($stmt, "NAME");
echo $fg1;
echo('</td>
<td width="6%" >Phone Number:</td>
<td width="46%" >');
$fg2 = OCIResult($stmt, "PHONE");
echo $fg2;
echo('</td>
</tr>
<tr>
<td width="10%">E-mail</td>
<td width="80%" colspan="3">');
$fg3 = OCIResult($stmt, "EMAIL");
echo $fg3;
echo('</td>
</tr>
</table>
<hr/>
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
</tr>
<tr>
<td width="10%">Reason for message:</td>
<td width="90%">');
$fg4 = OCIResult($stmt, "REASON");
echo $fg4;
echo('</tr>
<tr>
<td width="10%">Type Message Here: </td>
<td width="90%">
');
$fg5 = OCIResult($stmt, "MESSAGE");
echo $fg5;
echo('</td>
</tr>
</table>');
} /*End of the First If. So now compute what to do if post isn't used */
else
{
echo('
<form name="ContactForm" onSubmit="Contact.php" >
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
</tr>
<tr>
<td width="6%" >Name:</td>
<td width="46%" ><input Type="text" name="Name" style="width:86%"/></td>
<td width="6%" >Phone Number:</td>
<td width="46%" ><input type="text" Name="Phone" style="width:86%"/></td>
</tr>
<tr>
<td width="10%">E-mail</td>
<td width="80%" colspan="3"><input type="text" name="Email" style="width:30%" /></td>
</tr>
</table>
<hr/>
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
</tr>
<tr>
<td width="10%">Reason for message:</td>
<td width="90%"><select name="Reason">
<option value="General Enquiry" >General Enquiry</option>
<option value="Returning Item" >Returning Item</option>
<option value="Missing Item" >Missing Item</option>
<option value="Price Negotiation">Price Negotiation</option>
</select>
</tr>
<tr>
<td width="10%">Type Message Here: </td>
<td width="90%"><textarea name="Message" rows="5" style="width:90%;height:100%;"></textarea> </td>
</tr>
</table>
<input type="submit" value="Send Message" style="width:95%; height:35px; margin-top:10px; background- color:#0F0"/>
</form>
');}
}
OCILogOff($connect);
?>
<br/>
</div>
<div id="Footer">
Links:<br/>
Home<br/>
Items<br/>
Order Form<br/>
faq/help<br/>
Contact Us<hr/>
<p align="left">
©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT104: Introduction to Web Development. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY
</p>
</div>
</div>
</body>
</html>

how to display data in two column with php

How can I display data in two columns?
<?php
$query = "SELECT * FROM `release` WHERE artist_id = '$rcode' AND label_id = '$id'";
$result = mysql_query($query);
$tr_no = mysql_num_rows($result);
while ($info = mysql_fetch_array($result)) {
?>
<div>
<table style="width: 100%">
<tr>
<td ><img src="../artwork/<?php echo $info['label_id']; ?>/<?php echo $info['ID']; ?>.jpg" width="100" height="100" /></td>
<td valign="top">
<table style="width: 100%">
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo $info['code']; ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo $info['name']; ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo trh($info['date']); ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<?php
}
?>
Normally I am using this for just one column.
What is the easiest way of displaying it in two columns with the same fields I have in this code?
The answer also depends on the way you'd like to show the info.
If we assume you have the following six artist_id's in your DB
1,2,3,4,5,6
in which way would you like to show them? This way
1 2
3 4
5 6
or this way?
1 4
2 5
3 6
Update: as you say you'd like to show them in the first way, the solution is pretty simple. Every pair iteration (0, 2, 4...) you should open the row and every odd iteration (1, 3, 5...) you should close it , so you'd have
<tr><td>0</td><td>1</td></tr><tr><td>2</td><td>3</td></tr>...
The code would be
<?php
$query = "SELECT * FROM `release` WHERE artist_id = '$rcode' AND label_id = '$id'";
$result = mysql_query($query);
$tr_no = mysql_num_rows($result);
$ii = 0; // Iterator
while ($info = mysql_fetch_array($result)) {
?>
<div>
<table style="width: 100%">
<?php if ($ii%2 == 0) { // If pair, we open tr?>
<tr>
<?php } ?>
<td ><img src="../artwork/<?php echo $info['label_id']; ?>/<?php echo $info['ID']; ?>.jpg" width="100" height="100" /></td>
<td valign="top">
<table style="width: 100%">
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo $info['code']; ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo $info['name']; ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px"><?php echo trh($info['date']); ?></td>
</tr>
<tr>
<td style="width: 45px; height: 20px;" class="style5">
</td>
<td style="width: 180px">
</td>
</tr>
</table>
</td>
<?php if ($ii%2 == 1) { // If odd, we close tr?>
</tr>
<?php } ?>
</table>
</div>
<?php $ii++; // We increment the iterator }
?>
You have several options depending on how fancy you want to get with your HTML/CSS. You can try to keep each to 50% width and float them left and the elements should automatically arrange themselves in two columns.
You can also be more explicit using a table-based layout. In this case, start with a and tag, then add elements inside your loop. After every two elements ( $index % 2 == 0), write a to start a new row.. then, after your loop is finished, close your . If you go this route, you'll want to make sure to add an extra if you've got an odd number of results from your query.
There may be more sophisticated ways to do this, but this is simple and straightforward enough to get the job done.
Unless you have a "LARGE" data set,
1) bring all the rows out into a numerically indexed array
2) divide the number of rows by two: x1 = 0; x2 = (int) count/2;
3) loop from 0 to count/2, creating a table with two columns,
3a) those indexed by x1++ in the first column
Get the total number of pictures, you can do that dynamically, and then put everything in a for loop as follows:
Let's say you want 9 pictures on three columns:
for ($i = 0; $i<=6; $i=($i + 3))
{
$result = mysql_query("select * from users order by id desc limit $i,3 ");
while(mysql_fetch_array($result))
{
//bla bla bla html code
}
}
Good luck.
<table border='1'><tr><?phpfor ($i = 0; $i<=17; $i=($i + 3)){echo "<td>$i</td>";}?></tr><tr><?phpfor ($n = 1; $n<=17; $n=($n + 3)){ echo "<td>$n</td>";}?></tr><tr><?phpfor ($m = 2; $m<=17; $m=($m + 3)){echo "<td>$m</td>";}?></tr></table>
|0|3|6|9|12|15|
|1|4|7|10|13|16|
|2|5|8|11|14|17|
Thank you :)
<table border='1'><?phpfor ($n = 0; $n<=2; $n++) {echo "<tr>";for ($i = $n; $i<=17; $i=($i + 3)){ echo "<td>$i</td>";}echo "</tr>";}?></table>
just use two loop like this
result
0 3 6 9 12 15
1 4 7 10 13 16
2 5 8 11 14 17

Categories