On Window resize, html table columns - php

I am working on making modifications to a website. I have copied the code of an html file with table and inserted my php code to generate the table. I am having issue with the table rendering on the page on window resize. Attached are the links for how the table looks when window is resize.
On window resize, my columns are becoming rows.
Table when viewed in full browser
It's a dynamically generated table using php. Here's the code: Any help would be appreciated.
Thanks in advance.
<DIV class="section-container">
<DIV id="layout" class="rsp_kvheader">
<!-- custom_1 -->
<table cellpadding="0" cellspacing="0" width="100%" border="0" style="table-layout: fixed;">
<tr>
<td>
<div align="left">
<TABLE style="background-color: #eee; background-image: url(http://eworksxl.web.com/repo/images/kv1.jpg);;;;;;;" width="100%" cellpadding="0" class="fullwidth" cellspacing="0" style="table-layout: fixed;">
<TBODY>
<TR>
<TD align="center"></TD>
</TR>
</TBODY>
</TABLE>
</div>
<br style="clear:both;">
<!-- ADD CUSTOM BLOCK -->
<div align="center" >
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: auto;">
<tr>
<td align="center" valign="top" >
<div align="left">
<DIV><img width="2000" title="" assetid="122087963" src="../../image/timesheet_1.jpg" height="550" style="width:2000px;height:370px;" border="0" alt="" mce_src="/matrix/servlet/ShowAsset;jsessionid=4C8960FFB6D8F307F69627A62EC4099A?id=122087963&_dt=1488490190826" selectedfileurl="../../files/timesheet_1.jpg"></DIV>
</div>
</td>
</tr>
</table>
</div>
<br style="clear:both;">
<div align="center" >
<table border="0" cellpadding="0" cellspacing="0" width="80%" style="table-layout: auto;">
<tr>
<td align="center" valign="top" >
<div align="left">
<TABLE width="80%" cellpadding="0" cellspacing="0" style="table-layout: auto;">
<TBODY>
<TR>
<TD align="left">
<DIV class="rsp_content section Content-1Column-Text">
<H1><?php echo $fname." ".$lname ?></H1>
<div class="container">
<div class="table-responsive">
<table class="table table-striped table-bordered" style="table-layout: auto;" width="80%">
<thead>
<tr>
<th style="text-align:center" width="5%">#</th>
<th style="text-align:center" width="19%">Date</th>
<th style="text-align:center" width="19%">Day</th>
<th style="text-align:center" width="19%">Hours</th>
</tr>
</thead>
<tbody>
<form action ="timesheet.php" method="post">
<?php
$today = date("Y-m-d");
// echo $today;
$first_day = date("Y-m-1");
// echo $first_day;
$date = $first_day;
$i=0;
$table = $empid."_user";
while (strtotime($date) <= strtotime($today)) {
// echo "$date\n";
$newDate = date("m-d-Y", strtotime($date));
$day = date("l", strtotime($date));
$i++;
$sql_statement="select hours from $table where work_date='$newDate'";
$sql_result= $conn->query($sql_statement);
// $row=mysqli_fetch_row($sql_result);
// $hour_entered=$row[0];
// echo $hour_entered;
if(($sql_result->num_rows) > 0){
$row=mysqli_fetch_row($sql_result);
$hour_entered=$row[0];
}else{
$hour_entered=null;
}
?>
<tr>
<?php if($day=="Sunday" || $day=="Saturday"){
?>
<td style="color:orange; border: double 3px black;" align="center" width="5%">
<?php echo $i ?>
</td>
<td style="color:orange; border: double 3px black;" align="center" width="19%">
<?php echo $newDate ?>
<input type="hidden" name="dates[]" value="<?php echo $newDate?>">
</td>
<td style="color:orange; border: double 3px black;" align="center" width="19%">
<?php echo $day ?>
</td>
<?php
if($hour_entered!=null){
?>
<td align="center" style="color:orange; border: double 3px black;" width="19%">
<input type="text" name="hours[]" id="hour_input" value="<?php echo $hour_entered ?>" style="text-align:center" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
<!-- <?php echo $hour_entered ?> -->
</td>
<?php
}else{
?>
<td align="center" style="color:orange; border: double 3px black;" width="19%">
<input type="text" name="hours[]" style="text-align:center" value="0" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
<!-- <?php echo $hour_entered ?> -->
</td>
<?php
}
?>
</tr>
<?php
}else{
?>
<tr>
<td align="center" width="5%">
<?php echo $i ?>
</td>
<td align="center" width="19%">
<?php echo $newDate ?>
<input type="hidden" name="dates[]" value="<?php echo $newDate?>">
</td>
<td align="center" width="19%">
<?php echo $day ?>
<!-- <input type="hidden" name="dates[]" <?php echo $day?> > -->
</td>
<?php
if($hour_entered!=null){
?>
<td align="center" width="19%">
<input type="text" name="hours[]" id="hour_input" value="<?php echo $hour_entered ?>" style="text-align:center" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
<!-- <?php echo $hour_entered ?> -->
</td>
<?php
}else{
?>
<td align="center" width="19%">
<input type="text" name="hours[]" style="text-align:center" value="0" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
<!-- <?php echo $hour_entered ?> -->
</td>
<?php
}
?>
</tr>
<?php
}
?>
<?php
$date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
}
?>
<!-- </tr> -->
<tr>
<td colspan="4" align="right">
<input type="submit" value="Submit">
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</div>
</td>
</tr>
</table>
</div>
<br style="clear:both;">
<div align="center" >
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td align="center" valign="top" >
<div align="left">
<TABLE style="width: 100%; background-color: #414141;" cellpadding="0" cellspacing="0">
<TBODY>
<TR>
<TD style="text-align: center;">
<SPAN style="color: #ffffff; text-decoration: none;">
<SPAN style="color: #ffffff; text-decoration: none;">
<BR><BR>Share This Page:<BR>
<div id='webcom-component-socialmediashare-17657540220791720'></div>
</SPAN>
</SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</div>
</td>
</tr>
</table>
</div>
<br style="clear:both;">
</tr>
</table>
<!-- END-OF custom_1 -->
</DIV>
</DIV>

Related

Php calculation is posting as 0

I am having a problem with getting the calculation to post anything but 0. all other post has the correct info from the form but the calculation is not working. all the data that comes from the inputs and the calculation of the total pallets works. It is just the total price.
The whole form:
if(!checkAdmin()) {
header("Location: login.php");
exit();
}
$page_limit = 10;
// filter GET values
foreach($_GET as $key => $value) {
$get[$key] = filter($value);
}
foreach($_POST as $key => $value) {
$post[$key] = filter($value);
}
$rs_all = mysql_query("select count(*) as total_all from users") or die(mysql_error());
list($all) = mysql_fetch_row($rs_all);
?>
<?php
$rs_pickup = mysql_query("select count(*) as total_all from pickups") or die(mysql_error());
list($pickup) = mysql_fetch_row($rs_pickup);
?>
<?php
$sql="SELECT companyid, company FROM company ";
$result=mysql_query($sql) or die(mysql_error());
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["companyid"];
$thing=$row["company"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</option>';
}
?>
<?php
?>
<?php
$err = array();
if($_POST['doPickup'] == 'Enter Pickup')
if(empty($err)) {
$companyid = $_POST['companyid'];
$sql_grd = "SELECT companyid, grade_a_pu, grade_b_pu, grade_c_pu, ns_pu, custom_pu FROM company WHERE companyid = $companyid";
$result_grd=mysql_query($sql_grd) or die(mysql_error());
while ($row_grd=mysql_fetch_array($result_grd))
{
$price_a = $row_grd["grade_a_pu"];
$price_b = $row_grd["grade_b_pu"];
$price_c = $row_grd["grade_c_pu"];
$price_ns = $row_grd["ns_pu"];
$price_cus = $row_grd["custom_pu"];
}
$total_credit = (($_POST['grade_a_pal']*$price_a)+($_POST['grade_b_pal']*$price_b)+($_POST['grade_c_pal']*$price_c)+($_POST['ns_pal']*$price_ns)+($_POST['cus_pal']*$price_cus));
$sql_insert = "INSERT into `pickups`
(`companyid`,`pu_date`,`trail_num`,`grade_a_pal`,`grade_b_pal`,`grade_c_pal`,`ns_pal`,`cus_pal`,`pal_pu`,`credit`)
VALUES ('$_POST[companyid]','$_POST[pu_date]','$_POST[trail_num]','$_POST[grade_a_pal]','$_POST[grade_b_pal]','$_POST[grade_c_pal]','$_POST[ns_pal]','$_POST[cus_pal]','$_POST[pal_pu]','$total_credit')";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
}
?>
<html>
<head>
<title>USMI Pallets, Inc. :: Pickup Entry Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#datepicker").datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
});
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php include("header.php"); ?>
<tr>
<td colspan="3" height="23" valign="top" style="background-color:#A42914 ">
</td>
</tr>
<?php include("admin_menu.php"); ?>
<td width="800" valign="top" style="padding: 10px;">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="myaccount">
<tr>
<td>Total Pickups: <?php echo $pickup;?></td>
</tr>
</table>
<p><?php
if(!empty($msg)) {
echo $msg[0];
}
?></p>
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td><form name="form1" method="get" action="pickup_ent.php">
<p align="center">Search Account:
<SELECT NAME=companyid id="q">
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>
<br>
</p>
<p align="center">
<input name="doSearch" type="submit" id="doSearch2" value="Search">
</p>
</form></td>
</tr>
</table>
<p>
<?php if ($get['doSearch'] == 'Search') {
$sql = "SELECT * FROM pickups WHERE companyid = '$_REQUEST[companyid]' ORDER BY pu_date DESC";
$rs_total = mysql_query($sql) or die(mysql_error());
$total = mysql_num_rows($rs_total);
if (!isset($_GET['page']) )
{ $start=0; } else
{ $start = ($_GET['page'] - 1) * $page_limit; }
$rs_results = mysql_query($sql . " limit $start,$page_limit") or die(mysql_error());
$total_pages = ceil($total/$page_limit);
?>
<?php
// outputting the pages
if ($total > $page_limit)
{
echo "<div><strong>Pages:</strong> ";
$i = 0;
while ($i < $page_limit)
{
$page_no = $i+1;
$qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']);
echo "$page_no ";
$i++;
}
echo "</div>";
} ?>
<form name "searchform" action="pickup_ent.php" method="post">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr bgcolor="#E6F3F9">
<td class="myheader">ID</td>
<td class="myheader">Company #</td>
<td class="myheader">Date</td>
<td class="myheader">Trailer Number</td>
<td class="myheader">Grade A</td>
<td class="myheader">Grade B</td>
<td class="myheader">Grade C</td>
<td class="myheader">Non-Std</td>
<td class="myheader">Custom</td>
<td class="myheader">Total Pickup</td>
<td class="myheader">Total Credit</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php while ($rrows = mysql_fetch_array($rs_results)) {?>
<tr>
<td> <div align="center"><?php echo $rrows['pickup_id']; ?></div> </td>
<td> <div align="center"><?php echo $rrows['companyid']; ?></div></td>
<td> <div align="center"><?php echo $rrows['pu_date']; ?></div></td>
<td> <div align="center"><?php echo $rrows['trail_num'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_a_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_b_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_c_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['ns_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['cus_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['pal_pu'];?></div></td>
<td> <div align="center">$<?php echo $rrows['credit'];?></div></td>
<td width="10%">Edit Delete</td>
</tr>
<tr>
<?php } ?>
</table>
<p><br>
</form>
<?php } ?>
</p>
<h2><font color="#FF0000">Pickup Entry
Page</font></h2>
<p> </p>
<form name "pickupform" action="pickup_ent.php" method="post">
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td>
Account:
<SELECT NAME=companyid>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT> </td>
</tr>
<tr>
<td>Date: <input name="pu_date" type="text" id="datepicker" /></td>
</tr>
<tr>
<td>Trailer #:<select name="trail_num" id="trail_num">
<option selected value=""></option>
<option value="1986-1">1986-1</option>
<option value="1986-2">1986-2</option>
<option value="1986-3">1986-3</option>
<option value="1986-4">1986-4</option>
<option value="1986-5">1986-5</option>
<option value="1986-6">1986-6</option>
<option value="1986-7">1986-7</option>
<option value="1986-8">1986-8</option>
<option value="1986-9">1986-9</option>
<option value="1986-10">1986-10</option>
<option value="1986-11">1986-10</option>
<option value="1986-12">1986-12</option>
</select></td>
</tr>
<tr>
<td>Grade A Pallets: <input id="grade_a_pal" name="grade_a_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Grade B Pallets: <input id="grade_b_pal" name="grade_b_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Grade C Pallets: <input id="grade_c_pal" name="grade_c_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Non-Standard Pallets: <input id="ns_pal" name="ns_pal" type="text" size="8"></td>
</tr>
<tr>
<td>Custom Pallets: <input id="cus_pal" name="cus_pal" type="text" size="8"></td>
</tr>
<tr>
<tr>
<td>Total Pallets Picked Up:
<input id="pal_pu" name="pal_pu" type="text" size="8" readonly></td>
</tr>
<td><input name="doPickup" type="submit" id="doPickup" value="Enter Pickup"></p>
</td>
</tr>
</table>
<script>
$(document).ready(function() {
//this calculates values automatically
sum();
$("#grade_a_pal, #grade_b_pal, #grade_c_pal, #cus_pal").on("keydown keyup", function() {
sum();
});
});
function sum() {
var grade_a_pal = document.getElementById('grade_a_pal').value;
var grade_b_pal = document.getElementById('grade_b_pal').value;
var grade_c_pal = document.getElementById('grade_c_pal').value;
var ns_pal = document.getElementById('ns_pal').value;
var cus_pal = document.getElementById('cus_pal').value;
var result = parseInt(grade_a_pal) + parseInt(grade_b_pal) + parseInt(grade_c_pal) + parseInt(ns_pal) + parseInt(cus_pal);
if (!isNaN(result)) {
document.getElementById('pal_pu').value = result;
}
}
</script>
</form>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
<tr>
<td colspan="3" height="43" valign="top" style="background-color:#A42914 ">
<table width="766" style="height:100% " border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="myfooter">
<div style="margin:12px 0px 0px 31px; ">
© 2012 USMI Pallets, Inc. All rights reserved
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
It appears you are using $_post (lower case) instead of $_POST (uppercase) for your pallets vars.
Try outputting a print_r($_POST) to see what you are getting in your $_POST array. It could just be you are referencing the wrong vars.

Syntax Error on my php script

I am getting this error message when run the code below. Below is the code that is giving me error messages. This is the error message
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\jq\fines\admin\portal.php on line 218
My code:
<body class="easyui-layout">
<div region="north" class="title" border="false" style="height:40px;">
Client Services Admin Portal
</div>
<div region="center" border="false">
<div id="pp" style="position:relative">
<div style="width:30%;">
<div title="Time" style="text-align:center;background:#f3eeaf;height:170px;padding:5px;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100" height="100">
<param name="movie" value="http://www.respectsoft.com/onlineclock/analog.swf">
<param name=quality value=high>
<param name="wmode" value="transparent">
<embed src="http://www.respectsoft.com/onlineclock/analog.swf" width="100" height="100" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"></embed>
</object>
</div>
<div title="Current Users Logged On" collapsible="true" closable="false" style="height:250px;padding:3px;">
<center>
<?php require_once "fines/admin/usersloggedon.php"; ?>
</center>
</div>
</div>
<div style="width:70%;">
<div title="Search for receipt" closable="false" style="height:170px;padding:10px;">
<center>
<form action="" method="post" id="receiptnumSearch">
<input type="hidden" name="check" value="submitted">
<input class="easyui-searchbox" style="width:200px" name="receiptnum" data-options="prompt:'',searcher:doReceiptSearch">
</form>
<br/>
<div style="background-color:#3FF; height:1px"> </div><br/>
<?php
require_once"functions.php";
if($_POST['check']=='submitted')//open1
{
//checking for errors
$receiptnum=trim($_POST['receiptnum']);
if($receiptnum=='')//open
{
//System error
echo SysError('Search field empty', 'index.php?t='.urlencode(base64_encode("admin_fins")).'&o='.md5(date('Y-m-d : t')).'');
die();
}//closed
elseif(!empty($receiptnum))//open
{
?><table class='tablestyle2' width=95% cellpadding=2 cellspacing=0>
<tr valign=top>
<td ><table width="100%" border="0" cellspacing="0" cellpadding="0" class='tablestyle_inner'>
<tr>
<td width="40%" class='tableheader' height="25">Paid From Library</td>
<td width="30%" class='tableheader'>Patron Name</td><td width="30%" class='tableheader'>Receipt Number</td>
</tr>
<?php
$db1w = new PDO('mysql:host=10.40.254.229;dbname=koha_msulibrary;charset=utf8', 'root', 'philly');
$gt_r=$db1w->query("SELECT * FROM fine, borrowers,branch_libs where borrowers.cardnumber=fine.cardnumber AND branch_libs.brunchid=fine.brunchid AND fine.receiptNum='$receiptnum' LIMIT 0,1");
$gt_r_results=$gt_r->fetch(PDO::FETCH_ASSOC);
echo'
<tr>
<td class=\'label\' height="25" align="center">'.$gt_r_results['branch_name'].'</td>
<td class=\'label\' align="center">'.ucwords(strtolower($gt_r_results['firstname'].' '.$gt_r_results['surname'])).'</td>
<td class=\'label\' align="center"><a target="_blank" href="http://www.msu.ac.zw/libraries/jq/fines/receipt.php?invoice='.base64_encode('invoce_view').'&t='.base64_encode($gt_r_results['receiptNum']).'">'.$gt_r_results['receiptNum'].'</a></td>
</tr>';
?>
</table></td></tr></table>
<?
}//closed
}//closed
?>
</center>
</div>
<div title="Library Fines Statistics" closable="false" style="height:250px;text-align:center;">
<center>
<br/><form action="" id="date_range" method="post"><table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"><input type="hidden" name="date_r" value="date_r"><input name="data1" class="easyui-datebox" value="Start Date" width="200px"></input></td>
<td width="37%"><input name="data2" class="easyui-datebox" value="End Date" width="200px"></input></td>
<td width="24%">View Fines</td>
</tr>
</table></form>
<br/>
<?php
$data1=$_POST['data1'];
$data2=$_POST['data2'];
$date_r=$_POST['date_r'];
$dat=date('Y-m-d');
$da_1=strtotime($data1);
$data_=date('Y-m-d',$da_1);
//$da_2=strtotime($data2_);
//$data2=date('Y-m-d',$da_2);
//checking if date is real date
if((!isRealDate($data1) or !isRealDate($data2) or $dat < $data_ ) and $date_r=='date_r')
{
echo SysError('Incorrect date range', 'index.php?t='.urlencode(base64_encode("admin_fins")).'&o='.md5(date('Y-m-d : t')).'');
die();
}
//end of check
else{
?>
<table width=95% height="125" cellpadding=2 cellspacing=0 class='tablestyle2'>
<tr valign=top><td ><table width="100%" height="122" border="0" cellpadding="0" cellspacing="0" class='tablestyle_inner'> <tr> <td width="50%" class='tableheader' height="19">Branch Library</td> <td width="50%" class='tableheader'>
<?php
if($date_r=='date_r')
{
echo 'Fine collected between '.$data1.' and '.$data2;
}
else
{
echo 'Fines Collected to Date';
}
?></td>
</tr>
<tr>
<td class='label' height="12" >Batanai Library</td>
<td class='label' style="padding-left:10px">
<?php //checking if the date is real
if($date_r!='date_r')
{
echo GETbranchlibs('2');
}
elseif($date_r=='date_r')
{
echo GetBrunchLibsRange($data1,$data2,'2');
}
?></td>
</tr>
<tr>
<td class='label' height="6">GSBL</td>
<td class='label' style="padding-left:10px">
<?php
if($date_r!='date_r')
{
echo GETbranchlibs('3');
}
elseif($date_r=='date_r')
{
echo GetBrunchLibsRange($data1,$data2,'3');
}
?></td>
</tr>
<tr>
<td class='label' height="3" >Law Library</td>
<td class='label' style="padding-left:10px"><?php
if($date_r!='date_r')
{
echo GETbranchlibs('4');
}
elseif($date_r=='date_r')
{
echo GetBrunchLibsRange($data1,$data2,'4');
}
?></td>
</tr>
<tr>
<td class='label' height="3" >Main Library</td>
<td class='label' style="padding-left:10px"><?php
if($date_r!='date_r')
{
echo GETbranchlibs('1');
}
elseif($date_r=='date_r')
{
echo GetBrunchLibsRange($data1,$data2,1);
}
?></td>
</tr>
<tr>
<td class='label' height="2" >Total</td>
<td class='label' style="padding-left:10px; font-weight:bold;"><u><?php
if($date_r!='date_r')
{
echo GETbranchlibs('0');
}
elseif($date_r=='date_r')
{
echo GetBrunchLibsRange($data1,$data2,'0');
}
}
?></u></td>
</tr>
</table></td></tr></table></center>
</div>
</div>
</div>
</div>
You wrote somewhere in there
<? instead of <?php
So just change that and it will work. Tested on http://www.compileonline.com/execute_php_online.php

open a div having id using onclick in a hyperlink

below is the given div having id "panel" and links in the same page but outside this div, when I click on the link this div should be open. there are several links so jquery does not work and my button is created dynamically through php while loop hence i cannot put unique id in my hyperlink
<div id="panel">
<form name="userloginform" action="xxx.php" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="tb">
<tr>
<td align="left" valign="middle" height="80">User Name</td>
<td align="left" valign="middle">: </td>
<td align="left" valign="middle"><input name="user" type="text" class="log"/></td>
</tr>
<tr>
<td align="left" valign="middle">Password</td>
<td align="left" valign="middle">: </td>
<td align="left" valign="middle"><input name="pass" type="password" class="log"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"><input name="submit1" type="submit" value="Login" class="login_btn"/></td>
</tr>
</table>
</form>
</div>
and my link is
<a href="#" id="flip" >Launch Now</a>
<a href="#" id="" >Launch Now</a>
If I am not clear please reply which part is not clear so that I can edit and provide useful information clearly
ok here is where link is coming from, a CMS is used here.
<?php
$sql=mysql_query("SELECT * FROM heading ORDER BY id DESC");
while($r=mysql_fetch_array($sql))
{
$ii=$r['id'];
?>
<h3><?php echo $r['heading'];?></h3>
<div>
<div class="content">
<div class="main_table_wrapper">
<table width="1030" border="0" cellspacing="0" cellpadding="0" align="left">
<?php
$sql2=mysql_query("SELECT * FROM inner_table WHERE head='$ii'") ;
while($rows=mysql_fetch_array($sql2))
{
$abc=str_replace($rows['url'],'XXXXXXXXXXXXXXX',$rows['url']);
?>
<tr>
<th align="left" valign="middle" width="350"><?php echo $rows['inner_names'];?></th>
<th align="left" valign="middle" width="250"><?php echo $abc;?></th>
<th align="left" valign="middle" width="200"><?php echo $rows['author'];?></th>
<th align="center" valign="middle" width="100"><?php echo $rows['doe'];?></th>
<th align="right" valign="middle" width="130"><span class="lunch">Launch Now</span></th>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
<?php } ?>
</div>
You can't have multiple elements with the same id.
Since you didn't show any JS code so far, the only advice I can give is to use a class as the identifier for the action link.
From the look of your markup you could also use something along
$('span.lunch').on('click', 'a', function(e) { //do stuff } );

No data displayed on browser, but it is saved on the database

Here is my php code
<?php
include "conn.php";
if(isset($_POST['submit'])){
$id_guru=htmlentities($_POST['id_guru']);
$id_pelajaran=htmlentities($_POST['id_pelajaran']);
$id_kelas=htmlentities($_POST['id_kelas']);
$query=mysql_query("insert into tbl_jadwal values('','$id_guru','$id_pelajaran','$id_kelas')");
if($query){
?><script language="javascript">document.location.href="?page=jadwal_pengajaran&status=1";</script><?php
}else{
?><script language="javascript">document.location.href="?page=jadwal_pengajaran&status=2";</script><?php
}
}else{
unset($_POST['submit']);
}
?>
<!-- start page-heading --><title>Sistem Informasi SMP YPPI</title>
<div id="page-heading">
<h1>Jadwal Pengajaran</h1>
</div>
<!-- end page-heading -->
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
<th class="topleft"></th>
<td id="tbl-border-top"> </td>
<th class="topright"></th>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
<td id="tbl-border-left"></td>
<td>
<!-- start content-table-inner ...................................................................... START -->
<div id="content-table-inner">
<?php
if($_GET['status']=='1'){
?>
<div id="message-green">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="green-left">Data Tersimpan</td>
<td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif" alt="" /></a></td>
</tr>
</table>
</div>
<?php
}
if($_GET['status']=='0'){
?>
<div id="message-red">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="red-left">Gagal Menyimpan</td>
<td class="red-right"><a class="close-red"><img src="images/table/icon_close_red.gif" alt="" /></a></td>
</tr>
</table>
</div>
<?php
}
?>
<form action="?page=jadwal_pengajaran" method="post">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td><!-- start step-holder -->
<!-- end step-holder -->
<!-- start id-form -->
<table border="0" cellpadding="0" cellspacing="0" id="id-form">
<tr>
<th valign="top">Guru</th>
<td><select name="id_guru" class="styledselect_form_1">
<?php
$guru=mysql_query("select * from data_guru order by nama_guru asc");
while($row1=mysql_fetch_array($guru)){
?>
<option value="<?php echo $row1['id_guru'];?>"><?php echo $row1['nama_guru'];?> [ <?php echo $row1['nip'];?> ] <option>
<?php
}
?>
</select>
</td>
<td></td>
</tr>
<tr>
<th valign="top">Pelajaran</th>
<td><select name="id_pelajaran" class="styledselect_form_1">
<?php
$pelajaran=mysql_query("select * from setup_pelajaran order by nama_pelajaran asc");
while($row2=mysql_fetch_array($pelajaran)){
?>
<option value="<?php echo $row2['id_pelajaran'];?>"><?php echo $row2['nama_pelajaran'];?></option>
<?php
}
?>
</select>
</td>
<td></td>
</tr>
<tr>
<th valign="top">Kelas</th>
<td><select name="id_kelas" class="styledselect_form_1">
<?php
$kelas=mysql_query("select * from setup_kelas order by nama_kelas asc");
while($row3=mysql_fetch_array($kelas)){
?>
<option value="<?php echo $row3['id_kelas'];?>"><?php echo $row3['nama_kelas'];?></option>
<?php
}
?>
</select>
</td>
<td></td>
</tr>
<tr>
<th> </th>
<td valign="top"><input type="submit" name="submit" class="form-submit" />
<input type="reset" class="form-reset" />
</td>
<td></td>
</tr>
</table>
<!-- end id-form -->
</td>
<td><!-- start related-activities -->
</td>
</tr>
<tr>
<td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
<td></td>
</tr>
</table>
</form>
<p><em>*Tidak boleh 1 Kelas, 1 Pelajaran di ajarkan oleh 2 Guru atau lebih<br /></em> </p>
<p> </p>
<!-- start product-table ..................................................................................... -->
<form id="mainform" action="">
<table border="0" width="71%" cellpadding="0" cellspacing="0" id="product-table">
<tr>
<th width="13%" class="table-header-repeat line-left minwidth-1">Nomor </th>
<th width="24%" class="table-header-repeat line-left minwidth-1">Nama Guru</th>
<th width="26%" class="table-header-repeat line-left minwidth-1">NIP</th>
<th width="24%" class="table-header-repeat line-left minwidth-1">Mata Pelajaran</th>
<th width="24%" class="table-header-repeat line-left minwidth-1">Kelas</th>
<th width="13%" class="table-header-options line-left">Aksi</th>
</tr>
**<?php
$view=mysql_query("*SELECT* FROM tbl_jadwal jadwal, setup_kelas kelas, setup_pelajaran pelajaran, data_guru guru where jadwal.id_kelas=kelas.id_kelas and jadwal.id_pelajaran=pelajaran.id_pelajaran and jadwal.id_guru=guru.id_guru order by id_jadwal asc");
$no=0;
while($row=mysql_fetch_array($view)){
?>
<tr>
<td><?php echo $no=$no+1;?></td>
<td><?php echo $row['nama_guru'];?></td>
<td><?php echo $row['nip'];?></td>
<td><?php echo $row['nama_pelajaran'];?></td>
<td><?php echo $row['nama_kelas'];?></td>
<td class="options-width">
</td>
</tr>
<?php
}
?>
</table>
<!-- end product-table................................... -->
</form>
<div class="clear"></div>
</div>
<!-- end content-table-inner ............................................END -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
<th class="sized bottomleft"></th>
<td id="tbl-border-bottom"> </td>
<th class="sized bottomright"></th>
</tr>
</table>**
When i test the code on browser, there's nothing displayed, only empty table, but there is saved data on the database.
I believe the problem came from
**<?php
$view=mysql_query("*SELECT* FROM tbl_jadwal jadwal, setup_kelas kelas, setup_pelajaran pelajaran, data_guru guru where jadwal.id_kelas=kelas.id_kelas and jadwal.id_pelajaran=pelajaran.id_pelajaran and jadwal.id_guru=guru.id_guru order by id_jadwal asc");
$no=0;
while($row=mysql_fetch_array($view)){
?>
<tr>
<td><?php echo $no=$no+1;?></td>
<td><?php echo $row['nama_guru'];?></td>
<td><?php echo $row['nip'];?></td>
<td><?php echo $row['nama_pelajaran'];?></td>
<td><?php echo $row['nama_kelas'];?></td>
<td class="options-width">
</td>
</tr>
<?php
}
?>
But still I can't figure out what the problem is.
is that
$view=mysql_query("*SELECT* FROM ...
from the paste, it should look like this:
$view=mysql_query("SELECT * FROM ...
and
while($row=mysql_fetch_array($view)){
will give you a numbered array, not an associative array. Thus you need to EITHER access fields in their order:
<td><?php echo $row[0];?></td>
<td><?php echo $row[1];?></td> ...
or use assoc (NOT BOTH):
while($row=mysql_fetch_assoc($view)){

Passing value inside JavaScript function and saving it into a PHP variable

I am creating an application like that of Facebook photo albums having comments.
I have a webpage, which shows the pics inside an album, when a pic is clicked, a lightbox opens up, and the caption and comments on the pic will be shown. Here's the pictures.php code
<?php
session_start();
ob_start;
include('connection.php');
?>
<html>
<head>
<title>Photos</title>
<style type="text/css">
.wraptocenter
{
width: 200px;
height: 150px;
overflow: hidden;
}
.wraptocenter img
{
vertical-align: top;
}
.black_overlay
{
display: none;
position: fixed;
top: 0%;
left: 0%;
width: 100.7%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=80);
}
.white_imagebox
{
display: none;
position: fixed;
top: 5%;
left: 6%;
width: 900px;
height: 500px;
padding: 0px;
border: 0px solid #a6c25c;
background-color: white;
z-index: 1002;
overflow: visible;
}
</style>
<script type="text/javascript" src="AJAX/AjaxInsertPicComment.js"></script>
<script>
function showpic(image_path,image_id,album_id,pic_caption)
{
document.getElementById('AlbumDiv').style.display = "block";
document.getElementById('fade').style.display = "block";
document.getElementById('image').src = image_path; // this line added
img = new Image();
img.src = image_path;
document.getElementById('t_albumid').value = album_id;
document.getElementById('t_imageid').value = image_id;
document.getElementById('t_albid').value = album_id;
document.getElementById('t_picid').value = image_id;
document.getElementById('albumid').value = album_id;
document.getElementById('imageid').value = image_id;
document.getElementById('t_imagepath').value = image_path;
document.getElementById('caption_holder').value = pic_caption;
if(img.width > 500 && img.height > 450)
{
if(img.width > img.height)
{
document.getElementById('image').style.width = "500px";
document.getElementById('image').style.height = 'auto';
delete img;
return false;
}
else
{
document.getElementById('image').style.height = "450px";
document.getElementById('image').style.width = 'auto';
delete img;
return false;
}
}
else if(img.height > 450 && img.width < 500)
{
document.getElementById('image').style.height = "450px";
delete img;
return false;
}
else if(img.height < 450 && img.width > 500)
{
if(img.width > img.height)
{
document.getElementById('image').style.width = "500px";
document.getElementById('image').style.height = 'auto';
delete img;
return false;
}
else
{
document.getElementById('image').style.height = "450px";
document.getElementById('image').style.width = 'auto';
delete img;
return false;
}
}
else if(img.width < 500 && img.height < 450)
{
if(img.width > img.height)
{
document.getElementById('image').style.width = "500px";
document.getElementById('image').style.height = 'auto';
delete img;
return false;
}
else
{
document.getElementById('image').style.height = "450px";
document.getElementById('image').style.width = 'auto';
delete img;
return false;
}
}
delete img;
alert("humm");
return false;
}
</script>
</head>
<body>
<div id="photo_holder">
<table width="1000px" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="50px" align="center"/>
<td align="center" colspan="2" background="Images/header_menu.png" style="padding-right:2px;">
<?php include('header.php');?>
</td>
<td width="50px" align="center"/>
</tr>
<tr>
<td width="50px" align="center" ></td>
<td width="600px" align="center">
<?php
$album_id=$_REQUEST['txt_albumid'];
echo $album_id;
/* how many columns */
$column_number='3';
/* html table start */
?>
<div id="photo_container" align="center" width="600px">
<table border="1px" cellspacing="5" cellpadding="0" align="left">
<?php
$sql="SELECT * FROM candidate_pics WHERE album_id='$album_id'";
$result=mysql_query($sql,$con);
// $row=mysql_fetch_array($result);
$recordcounter=1; /* counts the records while they are in loop */
while($row=mysql_fetch_array($result))
{
/* decide if there will be new Table row (<TR>) or not ... left of division by column number is the key */
if($recordcounter%$column_number==1)
{
echo "<tr>";
}
?>
<td align="center" width="200px">
<div class="wraptocenter" align="center">
<?php $_SESSION['pic_id']=$row[pic_id];?>
<a href="javascript:void(0)"
onClick="showpic('<?php echo $row[pic_path];?>','<?php echo $row[pic_id];?>',
'<?php echo $row[album_id];?>','<?php echo $row[pic_caption];?>')";>
<img src="<?php echo $row[pic_path];?>"/></a>
</div>
</td>
<?php
/* decide if there will be end of table row */
if($recordcounter%$column_number==0)
{
echo "</tr>";
}
$recordcounter++; /* increment the counter */
}
if(($recordcounter%$column_number)!=1){ echo "</tr>"; }
?>
</table>
</div>
</td>
<td width="300px" align="center" >
<div id="photo_uploader">
<form method="post" action="photo_upload.php" enctype="multipart/form-data">
<table width="300px" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" width="100px">Upload Pic::</td>
<td align="center" width="200px">
<input type="file" name="file" id="file" style="width: 200px;"/>
</td>
</tr>
<tr>
<td align="center" width="100px"/>
<td align="center" width="200px">
<input type="submit" name="submit_pic" id="submit_pic" value="Click to upload" style="width: 200px;"/>
<input name="txt_albumid" type="hidden" value="<?php echo $album_id;?>"/>
</td>
</tr>
</table>
</form>
</div>
</td>
<td width="50px" align="center" ></td>
</tr>
</table>
</div>
<div id="AlbumDiv" class="white_imagebox">
<table align="center" cellpadding="0" cellspacing="0" border="0" width="900px">
<tr>
<td colspan="2" height="25px">
<div id="close">
<a href="javascript:void(0)"
onclick="document.getElementById('AlbumDiv').style.display =
'none';document.getElementById('fade').style.display='none'">
<img src="images/close-icon.png" style="border-style: none; border-color: inherit;
border-width: 0px; height: 17px; width: 16px;" align="right" /></a>
</div>
</td>
</tr>
<tr>
<td width="600px" align="center">
<table width="600px" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50px" align="center"/>
<td align="center" width="500px">
<div id="image_holder" style="width: 500px; height: 450px;
background-color:#666666;">
<input type="image" id="image" name="image"/>
</div>
</td>
<td width="50px" align="center"/>
</tr>
<tr>
<td/>
<td>
<input type="text" id="caption_holder" name="caption_holder"
style="width:500px;"/>
</td>
<td/>
</tr>
</table>
</td>
<td width="300px" align="center">
<table width="300px" cellpadding="0" cellspacing="0" border="0" align="top">
<tr>
<td align="center" width="100px">
<form method="post" action="photo_delete.php">
<input type="submit" name="delete" id="delete" value="Delete"
class="button" style="width: 100px;"/>
<input type="hidden" name="t_imageid" id="t_imageid"/>
<input type="hidden" name="t_imagepath" id="t_imagepath"/>
<input type="hidden" name="t_albumid" id="t_albumid"/>
</form>
</td>
<td align="center" width="100px">
<form>
<input type="button" name="edit" id="edit" value="Edit" class="button"
style="width: 100px;"
onclick="document.getElementById('pic_caption').style.visibility = 'visible';
document.getElementById('enter_caption').style.visibility = 'visible';"/>
</form>
</td>
<td align="center" width="100px">
<form method="post" action="">
<input type="submit" name="cover_pic" id="cover_pic" value="Set CoverPic" class="button"
style="width: 100px;"/>
<input type="hidden" name="t_albumname" id="t_albumname"/>
<input type="hidden" name="t_imagename" id="t_imagename"/>
</form>
</td>
</tr>
<tr>
<td height="100px" colspan="3">
<form method="post" action="photo_edit.php">
<input type="text" name="pic_caption" id="pic_caption" style="visibility:hidden;"/>
<input type="submit" name="enter_caption" id="enter_caption" style="visibility:hidden;"/>
<input type="hidden" name="t_picid" id="t_picid"/>
<input type="hidden" name="t_albid" id="t_albid"/>
</form>
</td>
</tr>
<tr>
<td height="300px" colspan="3">
<div id="" style="overflow-y:scroll; height:300px;">
<table width="282px" cellpadding="0" cellspacing="0" border="0"
align="center">
<tr>
<td>
<?php
echo $_SESSION[pic_id];?>
<div id="message_report">
</div>
</td>
</tr>
<tr>
<td>
<form method="post" action=
"javascript:get(document.getElementById('pic_comment_form'));" name=
"pic_comment_form" id="pic_comment_form">
<table width="280px" cellpadding="0" cellspacing="0" border="0"
align="center" >
<tr>
<td width="100px">
<input type="text" name="comment" id="comment" style="width:100px"/>
</td>
<td width="80px"/>
<td width="100px">
<input type="submit" name="comment_enter" id="comment_enter" style="width:100px"/>
</td>
<tr>
<td>
<input type="hidden" name="albumid" id="albumid"/></td>
<td>
<input type="hidden" name="imageid" id="imageid"/></td>
<td>
<input type="hidden" name="user" id="user"
value="<?php echo $_SESSION[logged_user];?>"/></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="fade" class="black_overlay">
</div>
</body>
</html>
The code
<a href="javascript:void(0)"
onClick="showpic('<?php echo $row[pic_path];?>','<?php echo $row[pic_id];?>',
'<?php echo $row[album_id];?>','<?php echo $row[pic_caption];?>')";>
<img src="<?php echo $row[pic_path];?>"/></a>
pass the album_id, pic_id to the javascript functions which is then passed to the objects in the lightbox such as id="t_albumid", id="t_imageid"
I need to write a SQL query in the lightbox like this:
SELECT * FROM candidate_pics_comment WHERE pic_id='$VariableHavingPicId
but for this I must use the variable in the JavaScript image_id and pass it again to the lightbox div in the JavaScript. The code:
document.getElementById('t_imageid').value = image_id;
assigns the object, the value as image_id, but how can we assign the image_id to a php variable so that I can use it in the sql query?
I mean in the JavaScript can it be something like this:
function showpic(image_path,image_id,album_id,pic_caption)
{
<?php
$var = //assign the value image_id;?>
// rest of the code here;
}
I know it's not possible, but is there some trick to achieve this?
Moreover as I was experimenting, I did something like this:
function showpic(image_path,image_id,album_id,pic_caption)
{
<?php
$_SESSION[pic_id]="hmmm";?>
//rest codes;
}
Then when I used echo $_SESSION[pic_id] in php script, it displayed hmmm
So I was thinking can it be done something like this?
function showpic(image_path,image_id,album_id,pic_caption)
{
<?php
$_SESSION[pic_id]=//assign image_id to session variable;?>
//rest codes;
}
Besides I used AJAX application, but I saw that AJAX returns the response to the objects innerHTML, how ca it be stored in a php variable?
Update
My question is that, I am passing values from this
<a href="javascript:void(0)"
onClick="showpic('<?php echo $row[pic_path];?>','<?php echo $row[pic_id];?>',
'<?php echo $row[album_id];?>','<?php echo $row[pic_caption];?>')";>
<img src="<?php echo $row[pic_path];?>"/></a>
to the JavaScript fiunction
function showpic(image_path,image_id,album_id,pic_caption)
Now how can I assign image_id to a PHP variable which I can use in the div AlbumDiv which is used for the lightbox. If that not possible how can a session variable be assign the value of image_id, is it possible inside the JavaScript function?
ajax is the only option to get something from JavaScript to PHP.
If you are using jQuery then take a look at the docs here
Otherwise I recommend you use a Library like jQuery or jQuery itself

Categories