I have 2 problems in my code. But first here's the complete set of code
<html>
<title>IMS:MPP | Home</title>
<script type="text/javascript">
function PopupCenter(pageURL, title,w,h)
{
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
var state = new Array();
for (i=0; i<1; i++) {
state[i] = "none";
}
</script>
<head>
<link href="officerStyle.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
useMode:2,
target:"inputField",
cellColorScheme: "armygreen",
limitToToday:true,
});
};
$(function() {
$("#inputField1").JsDatePick();
}
)
;
</script>
<!-- End -->
<?php
if(isset($_REQUEST['inputField1']))
$inputField1 = $_REQUEST['inputField1'];
else
$inputField1 = "";
include('global.php');
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="mpp"; // Database name
$tbl_name="userinfo"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//$_SESSION['myusername'] = $row['Username'];
//$_SESSION['mypassword'] = $row['UserID'];
$myusername=$_SESSION['myusername'];
//$mypassword=$_SESSION['mypassword'];
//require("mainlogin.php");
//$id = $_SESSION['myusername']; //Get user's ID
$result = mysql_query("SELECT * FROM $tbl_name where Username='$myusername'");
$row = mysql_fetch_assoc($result);
$type = $row['UserType'];
?>
<body>
<div id="wrapper">
<div id="header">
<img id="logos" src="images/logo.png" style="opacity:0.7;filter:alpha(opacity=70)"
onmouseover="this.style.opacity=0.7;this.filters.alpha.opacity=70"
onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100" border="none"/>
<a href="logout.php" onclick="return confirm ('Are you sure you want to Log Out?')"><img id="out" src="images/Outbtn.png" style="opacity:0.7;filter:alpha(opacity=70)"
onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100"
onmouseout="this.style.opacity=0.7;this.filters.alpha.opacity=70" border="none"/></a>
</div>
<div id="page">
<div id="page-bgbtm">
<div id="menu">
<?php
/*------------------------------------------------------------ Encoder ------------------------------------------------------------*/
if ($type=="Encoder"){
//Navigation
echo " <ul>
<li class='current_page_item'> <a href='#'>Home</a> </li>
<li> <a href='SalesOfficer.php'>Sales</a> </li>
<li> <a href='PromoOfficer.php'>Promo</a> </li>
<li> <a href='BankOfficer.php'>Bank</a> </li>
<li> <a href='PlanOfficer.php'>Plan</a> </li>
<li> <a href='User.php'>User</a> </li>
<li> <a href='Client.php'>Client</a> </li>
</ul>
</div>";
//Texts
echo " <br/><br/><h1 class='title'><a href='#'>Welcome</a></h1>
<div class='entry'>";
echo "<h3>" . $row['UserType'] . " " . $row['FirstName'] . "</h3>";
echo "<div class='post'></br>
<h3 class='title'>TODAY: Walk-In Clients</a></h3>";
echo "<h4 class ='title'>" . date("F d, Y") . date(" (D)");
echo "</h4></div>";
//TableHeader
echo "<table border='1' cellpadding='5'>
<tr>
<th>Time In</th>
<th>Last Name</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Promo Officer Name</th>
<th>Action</th>
</tr>";
/*------------------------------------------------------------ GoToDateTable ------------------------------------------------------------*/
//GoToDate
echo " <link rel='stylesheet' type='text/css' media='all' href='jsDatePick_ltr.min.css' />";
echo"<form name='sdate' action='#' method='post'>";
echo"<input type='text' size='12' id='inputField' name='inputField1'>";
echo"<a href='#' onclick='validateForm(document.forms['sdate'].action);return false;><img src='images/go.png' height='27' width='60'></a>";
//GoToDateQuery
$result = mysql_query("SELECT TimeIn,LastName, FirstName, MiddleName ,PromoOfficerName FROM timein WHERE DateTrans='".$inputField1."'");
//TableAlternateFieldColor
$sw = 0;
while($row = mysql_fetch_array($result))
{
if($sw == 0)
{
$mycolor = "#fff";
$sw = 1;
}
else
{
$mycolor = "#79b669";
$sw = 0;
}
//TableRowAndTableData
echo "<tr bgcolor='".$mycolor."'>";
echo "<td>" . $row['TimeIn'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['MiddleName'] . "</td>";
echo "<td>" . $row['PromoOfficerName'] . "</td>";
echo "<td><image src='images/out.png' height=27 width=60></td>";
echo "</tr>";
}
/*------------------------------------------------------------ DateTodayTable ------------------------------------------------------------*/
$datetoday=date("m.d.Y");
$result = mysql_query("SELECT TimeIn,LastName, FirstName, MiddleName ,PromoOfficerName FROM timein WHERE DateTrans='".$datetoday."'");
$sw = 0;
while($row = mysql_fetch_array($result))
{
if($sw == 0)
{
$mycolor = "#fff";
$sw = 1;
}
else
{
$mycolor = "#79b669";
$sw = 0;
}
echo "<tr bgcolor='".$mycolor."'>";
echo "<td>" . $row['TimeIn'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['MiddleName'] . "</td>";
echo "<td>" . $row['PromoOfficerName'] . "</td>";
echo "<td> <a href='#' onclick = PopupCenter('timeoutform.php?salesID=<?$row['PlanHoldersID']?>','myPop1',400,430)><image src='images/out.png' height=27 width=60> </a> </td>";
echo "</tr>";
}
echo "<a href='#' onclick = PopupCenter('timeinform.php','myPop1',400,430)> <img src = 'images/add.png' height='27' width='60'> </a>";
}
/*------------------------------------------------------------ Administrator ------------------------------------------------------------*/
elseif ($type=="Administrator"){
echo "<ul>
<li class='current_page_item'> <a href='#'>Home</a> </li>
<li> <a href='#'>Daily</a> </li>
<li> <a href='#'>Weekly</a> </li>
<li> <a href='#'>Commission</a> </li>
<li> <a href='#'>Client</a> </li>
</ul> </div>";
echo " <br/><br/><h1 class='title'><a href='#'>Welcome</a></h1>
<div class='entry'>";
echo "<h3>" . $row['UserType'] . " " . $row['FirstName'] . "</h3>";
}
?>
</div>
</div>
</div>
</div>
<div id="footer-wrapper">
<div id="footer">
<p>Copyright (c) 2010 Sitename.com. All rights reserved. Design by FCT.</p>
</div>
</div>
</body>
</html>
Problem 1:
//GoToDate
echo " <link rel='stylesheet' type='text/css' media='all' href='jsDatePick_ltr.min.css' />";
echo"<form name='sdate' action='#' method='post'>";
echo"<input type='text' size='12' id='inputField' name='inputField1'>";
echo"<a href='#' onclick='validateForm(document.forms['sdate'].action);return false;><img src='images/go.png' height='27' width='60'></a>";
This is a textbox which gets the date and a button which triggers the query to show the data under the given date. The problem is it works when date is manually entered but it doesn't when the datepicker is used.
Problem 2:
echo "<td> <a href='#' onclick = PopupCenter('timeoutform.php?salesID=<?$row['PlanHoldersID']?>','myPop1',400,430)><image src='images/out.png' height=27 width=60> </a> </td>";
echo "</tr>";
This button should show timeoutform.php
yet it shows the ff. errors
Parse error: parse error, expecting
T_STRING' or
T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\IMS-MPP(Encoder)\home.php on line 209
Hope someone could help. Thanks a lot!
"No need to write <?$row['PlanHoldersID']?>
replace with ".$row['PlanHoldersID']."
echo "<td> <a href='#' onclick = PopupCenter('timeoutform.php?salesID=".$row['PlanHoldersID'].",'myPop1',400,430)><image src='images/out.png' height=27 width=60> </a> </td>";
For problem 2, you've got some wonky formatting. Try this:
echo "<td> <a href='#' onclick = PopupCenter('timeoutform.php?salesID=".$row['PlanHoldersID']."','myPop1',400,430)><image src='images/out.png' height=27 width=60> </a> </td>";
Basically, PHP was printing "<?$row['PlanHoldersID']?>"
as a string inside the HTML.