how to get the content of current webpage in mpdf library - php

i have the below code written, actually i thought of converting the current webpage to pdf document, but i couldnt make how to declare the current url and get the contents of the webpage in pdf doc. below is my code.
<?php
require("mpdf60/mpdf.php");
$mpdf=new mPDF('utf-8','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->SetHeader('|Your Header here|');
$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetDisplayMode('fullpage');
$mpdf->debug = true;
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php
include "contractview.php?ID=129";
//This is your php page ?>
<?php
$html = ob_get_contents();
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>
i have written include "contractview.php?ID=129"; but this was not working, can any one please help me in how to assign this to get the current page contents.

MPDF doesn't support includes. You have to put it in a var. The full html can be converted using jquery or in php with file_get_contents.
This is how i did it with full page.
<?php
require("mpdf60/mpdf.php");
$mpdf=new mPDF('utf-8','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->SetHeader('|Your Header here|');
$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetDisplayMode('fullpage');
$mpdf->debug = true;
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php
//$content = file_get_contents("contractview.php?ID=129"); //<=== WRONG ONE
$content = file_get_contents("http://www.yourwebsite.com/contractview.php?ID=129"); //<=== getting content from url and not file!!
print($content);
//This is your php page ?>
<?php
$html = ob_get_contents($content); //<=== put content in ob
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>
I see you are using ob_start and ob_end
You coudl also use
<?php
require("mpdf60/mpdf.php");
$mpdf=new mPDF('utf-8','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->SetHeader('|Your Header here|');
$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetDisplayMode('fullpage');
$mpdf->debug = true;
// Buffer the following html with PHP so we can store it to a variable later
$content = file_get_contents("http://www.yourwebsite.com/contractview.php?ID=129"); //<=== getting content from url and not file!!
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($content);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>
<?php require_once ('header.php'); ?>
<!-- 10/15/2014 START: Freze table header row; Updated Fancybox so it works with jQuery 1.10.1 as well -->
<META content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" http-equiv="X-UA-Compatible">
<!--script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script duplicate 10/6/2015-->
<SCRIPT type="text/javascript" src="jQueryfloatThead/jquery.floatThead.js"></SCRIPT>
<SCRIPT type="text/javascript" src="jQueryfloatThead/site.js"></SCRIPT>
<SCRIPT type="text/javascript" src="jQueryfloatThead/bootstrap.js"></SCRIPT>
<SCRIPT type="text/javascript" src="jQueryfloatThead/less.js"></SCRIPT>
<!-- 10/15/2014 END -->
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border=0 cellpadding="0" cellspacing="0">
<tr><td height="36" background="images/topbar_bg.png" style="background-repeat:repeat-x;"><img src="images/topbar_bg.png" height="36"></td></tr>
<tr><td>
<table width="960" border=0 cellpadding="0" cellspacing="0" align="center">
<?php require_once ('topnav.php'); ?>
<tr><td>
<table width="100%" border=0 cellpadding="10" cellspacing="5">
<?php
if(!isset($_SESSION['Username'])) {
header('Location: home?errMsg=Your session has been expired. Please re-login again.');
}
?>
<tr><td bgcolor="#006ec7" valign="top" width="100%" class="headertd">FAR Compliance Portal</td></tr>
<tr><td bgcolor="#ebf4f9" valign="top" width="100%" height="300">
<?php
require_once ('dbconnection.php');
require_once ('contractcheck.php'); //Check if users can view this section
if (!isset($_REQUEST['ID'])) {
print "ERROR: No record has been selected.";
exit;
}
if (!is_numeric($_REQUEST['ID'])) {
print "ERROR: Invalid record has been selected.";
exit;
}
$thisID = $_REQUEST['ID'];
$sqlGet = "select * from far_contract where ID='" .$thisID. "'";
$resultGet = mysql_query($sqlGet, $dbconnection);
if (!$resultGet) {
echo 'Could not run query [1] ($thisID): ' . mysql_error();
exit;
}
$num_rows = mysql_num_rows($resultGet);
if ($num_rows==0 || $num_rows>1) {
print "Error: Invalid record is being called ($thisID). Please check with administrator.";
exit;
}
$row = mysql_fetch_array($resultGet);
$thisID = $row[0];
$thisContractNumber = $row[1];
$thisCustomer = $row[2];
$thisCeilingValue = $row[3];
//$thisEffectiveDate = $row[4];
//$thisExpirationDate = $row[5];
//$thisLegalEntity = $row[6];
$thisProjectName = $row[4];
$thisMFilesLink = $row[5];
$thisCreatedByID = $row[6];
$thisCreatedDate = $row[7];
$thisModifiedByID = $row[8];
$thisModifiedDate = $row[9];
$thisContractStatus = $row[10]; //12/22/2014
$thisNotes = $row[11]; //3/27/2015
$thisSubmittedByID = $row[17]; //10/1/2015
$thisSubmittedDate = $row[18]; //10/1/2015
$thisMasterAgreement = $row[19]; //10/6/2015
if ($thisContractStatus==NULL) $thisContractStatus="Not Submitted"; //12/22/2014
$thisSpecialStatusNotes = $row[15]; //4/15/2015
unset($resultGet);
//if ($thisEffectiveDate!="") $thisEffectiveDate = date("m/d/Y", strtotime($thisEffectiveDate));
//if ($thisExpirationDate!="") $thisExpirationDate = date("m/d/Y", strtotime($thisExpirationDate));
$sqlGetFAR = "select * from far_contract_clauses where ContractID='" .$thisID. "'";
$resultGet = mysql_query($sqlGetFAR, $dbconnection);
if (!$resultGet) {
echo 'Could not run query [2] ($thisID): ' . mysql_error();
exit;
}
$num_rows = mysql_num_rows($resultGet);
if ($num_rows>0) {
$thisSelectClause = "";
while ($row = mysql_fetch_array($resultGet)) {
if ($thisSelectClause=="")
$thisSelectClause = $row[2];
else
$thisSelectClause .= ",".$row[2];
}
}
unset($resultGet);
?>
<h1>Contract Records > View Record</h1>
<a href='php-to-pdf.php' target='_blank' ><input type='button' value='Convert to pdf'></a>
<table cellspacing=0 cellpadding=3 border=0 width="100%" class="table-bordered">
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>ID:</b></td>
<td class="resultTbl"><?php echo $thisID ?></td>
</tr>
<tr>
<td nowrap width="220" class="resultTbl" bgcolor='#d9e0e4'><b>Direct Customer's Solicitation/Contract Number:</b></td>
<td width="100%" class="resultTbl"><?php echo $thisContractNumber ?></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Direct Customer:</b></td>
<td class="resultTbl"><?php echo $thisCustomer ?></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Ceiling Value ($):</b></td>
<td class="resultTbl"><?php is_numeric($thisCeilingValue)? print "$ ".number_format($thisCeilingValue,2) : print ""; ?></td>
</tr>
<!--<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Effective Date:</b></td>
<td class="resultTbl"><//php echo $thisEffectiveDate //></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Expiration Date:</b></td>
<td class="resultTbl"><//php echo $thisExpirationDate //></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Rapiscan Legal Entity:</b></td>
<td class="resultTbl"><//php echo $thisLegalEntity //></td>
</tr>-->
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Project Name/Description:</b></td><?php //3/27/2015 ?>
<td class="resultTbl"><?php echo $thisProjectName ?></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>M-Files Link:</b></td>
<td class="resultTbl"><?php echo $thisMFilesLink ?></td>
</tr>
<tr><?php //3/27/2015 ?>
<td class="resultTbl" bgcolor='#d9e0e4' valign='top'><b>Notes:</b></td>
<td class="resultTbl"><?php echo $thisNotes ?></td>
</tr>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Created By:</b></td>
<td class="resultTbl"><?php echo fetchFullName($thisCreatedByID) . " on " . $thisCreatedDate ?></td>
</tr>
<?php
$SubmissionDate = $thisCreatedDate; //1/6/2015
if ($thisModifiedByID!="") { ?>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Last Modified By:</b></td>
<td class="resultTbl"><?php echo fetchFullName($thisModifiedByID) . " on " . $thisModifiedDate ?></td>
</tr>
<?php
$SubmissionDate = $thisModifiedDate; //1/6/2015
}
?>
<?php
$SubmittedDate = $thisSubmittedDate; //10/1/2015 Added Submitted By and Submitted Date
if ($thisSubmittedByID!="") { ?>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Submitted By:</b></td>
<td class="resultTbl"><?php echo fetchFullName($thisSubmittedByID) . " on " . $thisSubmittedDate ?></td>
</tr>
<?php
$SubmittedDate = $thisSubmittedDate; //10/1/2015
}
?>
<?php
$MasterAgreement = $thisMasterAgreement; //10/1/2015 Added Submitted By and Submitted Date
?>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Master/Framework<b>Agreement Contract</b></td>
<td class="resultTbl"><?php echo ($thisMasterAgreement==1)?'Yes':'No'; ?></td>
</tr>
<?php
?>
<tr>
<td class="resultTbl" bgcolor='#d9e0e4'><b>Status:</b></td>
<td class="resultTbl"><?php echo $thisContractStatus //12/22/2014 ?>
<?php //4/15/2015
if ($AllowContractFull) {
if ($thisContractStatus=="Submitted") {
print " ";
print "[Suspend]";
print " [Cancel]";
} elseif ($thisContractStatus=="Suspended") {
print " ";
print "[Re-activate]";
print " [Cancel]";
}
}
if (! ($thisSpecialStatusNotes=="" || is_null($thisSpecialStatusNotes)) ) {
print "<BR><font color=gray>$thisSpecialStatusNotes</font>";
}
?>
</td>
</tr>
<tr><td valign=top colspan=2 class="resultTbl"><b>FAR Clauses:</b></td></tr>
<tr><td valign=top colspan=2 class="resultTbl">
<?php
//get list of departments
$sql = "select * from far_departments order by Department";
$result = mysql_query($sql, $dbconnection);
if (!$result) {
echo 'Could not run query [3]: ' . mysql_error();
exit;
}
$deptList = array();
while ($row = mysql_fetch_array($result)) { //loop each department
$deptList[] = $row[1];
}
unset ($result);
printByCompliance ($thisID, $thisSelectClause, $thisContractStatus, $SubmissionDate); //1/6/2015
?>
</td>
</tr>
</table>
<?php
require_once ('logging.php'); //7/31/2014
mysql_close($dbconnection);
?>
</td></tr>
</table>
</td></tr>
<?php require_once ('footer.php'); ?>
</table>
</td></tr>
</table>
</body>
</html>
<?php
function printByCompliance ($thisID, $thisSelectClause, $thisContractStatus, $SubmissionDate){ //1/6/2015
global $deptList;
global $dbconnection;
//print table header
//echo "<h1>Compliance Report</h1>";
echo "<DIV id='options'><table width='100%' class='table table-bordered table-striped' cellspacing=0 cellpadding=5>";
echo "<thead><tr bgcolor='#d9e0e4'>";
echo "<th class='resultTbl' nowrap><b>FAR Clauses</b><img src='images/spacer.gif' width='80' height='1'></th>"; //9/15/2014
if ($thisContractStatus=="Submitted" || $thisContractStatus=="Suspended" || $thisContractStatus=="Cancelled") //4/15/2015
echo "<th class='resultTbl' nowrap><font color=blue><b>Certified<BR>as of<BR>".str_replace(" ", "<BR>", $SubmissionDate)."?</b></font></th>"; //1/6/2015
else
echo "<th class='resultTbl' nowrap><font color=blue><b>Certified?</b></font></th>"; //9/15/2014
foreach ($deptList as $EachDept) { //loop each dept
echo "<th class='resultTbl' align=center><b>" . $EachDept . "</b></th>";
}
echo "</tr></thead>"; //10/15/2014 END
//get all questions
$sql = "select * from far_questions where QStatus='ACTIVE' and ID in ($thisSelectClause) order by Title, Alternate"; //2/9/2015
$result = mysql_query($sql, $dbconnection);
if (!$result) {
echo 'Could not run query [4]: ' . mysql_error();
exit;
}
$listQuestionArray = array(); //START natural-order sorting questions by title
while ($row = mysql_fetch_array($result)) {
$listQuestionArray[] = array($row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]); //2/9/2015; 10/10/2014; 6/17/2014
}
usort($listQuestionArray, function ($elem1, $elem2) {
return strnatcmp ($elem1['1']." ".$elem1['7'], $elem2['1']." ".$elem2['7']);
//2/9/2015 need to take Alternate in nartural sort*** return strnatcmp ($elem1['1'], $elem2['1']);
});
unset($row); //END natural-order sorting questions by title
foreach ($listQuestionArray as $row) { //loop each question
$thisQuestionID = $row[0];
$thisTitle = trim($row[1]);
$thisURL = trim($row[2]);
$thisVersionDate = trim($row[3]);
$thisFrequency = trim($row[4]); //6/17/2014
$thisClauseType = trim($row[6]); //10/10/2014
$thisAlternate = trim($row[7]); //2/9/2015
$RequireDepartment = ""; //6/17/2014 START new tbl structure
if ($thisClauseType=="YELLOW") { //10/10/2014
$sqlgetdept = "select RequireDepartment from far_yellowDept where QuestionID='$thisQuestionID'";
} else {
$sqlgetdept = "select RequireDepartment from far_questionsDept where QuestionID='$thisQuestionID'";
} //10/10/2014
$resultgd = mysql_query($sqlgetdept, $dbconnection);
if (!$resultgd) {
echo 'Could not run query [6]: ' . mysql_error();
exit;
}
while ($rowgd = mysql_fetch_array($resultgd)) {
$RequireDepartment .= $rowgd[0] . ", ";
}
unset ($rowgd);
unset ($resultgd);
//$RequireDepartment = trim($row[5]);
//$thisFrequency = trim($row[6]); //6/17/2014 END
$curClauseInfo = ""; //9/15/2014 temp string for Clause info
$curClauseInfo .= "<td class=resultTbl bgcolor=#d9e0e4><a class='rptnav' href='" .$thisURL. "' target=new>" . $thisTitle . "</a>";
if ($thisVersionDate!="" && $thisVersionDate != NULL) {
$curClauseInfo .= "<BR>(" .$thisVersionDate. ")";
}
if ($thisAlternate!="" && $thisAlternate != NULL) { //2/9/2015
$curClauseInfo .= "<BR><BR>" .$thisAlternate;
}
$curStatusStr = ""; //9/15/2014 temp string to store current status for each dept for current FARS clause
$chkQuestion = true; //assume this question is compliance.
foreach ($deptList as $EachDept) { //loop each dept
if (strpos($RequireDepartment, $EachDept) !== false) { //if this question is required for current dept
$curStatusStr .= "<td class=resultTbl nowrap align=center>";
if ($thisClauseType=="YELLOW") { //10/10/2014
//12/11/2014 fetch approval status for YELLOW clause from new table
$sqlConApp = "select * from far_contract_approval where ContractID='$thisID' and QuestionID='$thisQuestionID' and Department='{$EachDept}'";
$resultConApp = mysql_query($sqlConApp, $dbconnection);
if (!$resultConApp) {
echo 'Could not run query [7]: ' . mysql_error();
exit;
}
$num_rowsConApp = mysql_num_rows($resultConApp);
if ($num_rowsConApp>0) { //if approval response is found
$rowConApp = mysql_fetch_array($resultConApp);
$curStatusStr .= "<B>Approved By</B><BR>" . fetchFullName($rowConApp[4]) . "<BR>" . str_replace(" ", "<BR>", $rowConApp[5]);
} else { //if NO approval response is found
$curStatusStr .= "Approval<BR>Required";
}
unset($resultConApp); //12/11/2014
$curStatusStr .= "</td>";
$chkQuestion=false;
} else { //10/10/2014 for clause type = CERTIFY and GREEN
//check for approval
$sqlConApp = "select * from far_contract_approval where ContractID='$thisID' and QuestionID='$thisQuestionID' and Department='{$EachDept}'";
$resultConApp = mysql_query($sqlConApp, $dbconnection);
if (!$resultConApp) {
echo 'Could not run query [7b]: ' . mysql_error();
exit;
}
$num_rowsConApp = mysql_num_rows($resultConApp);
if ($num_rowsConApp>0) { //if approval response is found
$rowConApp = mysql_fetch_array($resultConApp);
$curStatusStr .= "<B>Approved By</B><BR>" . fetchFullName($rowConApp[4]) . "<BR>" . str_replace(" ", "<BR>", $rowConApp[5]);
} else {
//get latest response per each question
$sql2 = "select * from far_responses where QuestionID=$thisQuestionID and Department='{$EachDept}' order by ResponseDate desc limit 1";
$result2 = mysql_query($sql2, $dbconnection);
if (!$result2) {
echo 'Could not run query [8]: ' . mysql_error();
exit;
}
$num_rows2 = mysql_num_rows($result2);
if ($num_rows2>0) { //if response is found
$row2 = mysql_fetch_array($result2);
$thisResponse = $row2[2];
$thisResponseBy = $row2[5];
$thisResponseDate = $row2[6];
$tempResponseDate = str_replace(" ", "<BR>", $thisResponseDate); //6/12/2014 show time on next line
$curStatusStr .= "<B>". $thisResponse . "</B><BR>" . $thisResponseBy . "<BR>" . $tempResponseDate;
if ($thisResponse=="YES") { //if latest response is YES, check if it has expired or not
/* 6/2/2014 Disable this function - no need to check Frequency as all answers will be reset on 1/1
$chkDate = strtotime($thisResponseDate);
$chkDate = strtotime("+$thisFrequency day", $chkDate);
if (time() > $chkDate) {
print "<font color=red><BR>Expired</font>";
$chkQuestion=false;
}
6/2/2014 */
} else { //PENDING or EXPIRED
$chkQuestion=false;
}
} else { //no previous submission
$curStatusStr .= "Response<BR>Pending";
$chkQuestion=false;
}
}
unset($resultConApp); //12/11/2014
$curStatusStr .= "</td>";
} //10/10/2014
} else { //this question does not apply to current dept
$curStatusStr .= "<td class=resultTbl align=center>N/A</td>";
}
}
$curStatusBox = ""; //9/15/2014 temp string to store green/red icon
$curStatusBox .= "<td class=resultTbl align=center bgcolor=#d9f1fe>";
if ($thisContractStatus=="Submitted" || $thisContractStatus=="Suspended" || $thisContractStatus=="Cancelled") { //4/15/2015; 1/6/2015 Contract has been submitted
$sqlFreezeStat = "select LightIndicator from far_contract_clauses where ContractID='$thisID' and QuestionID='$thisQuestionID'";
$resultFreezeStat = mysql_query($sqlFreezeStat, $dbconnection);
if (!$resultFreezeStat) {
echo 'Could not run query [10]: ' . mysql_error();
exit;
}
$num_rowsFS = mysql_num_rows($resultFreezeStat);
if ($num_rowsFS>0) { //if response is found
$rowFS = mysql_fetch_array($resultFreezeStat);
switch ($rowFS[0]) {
case "GREEN": $curStatusBox .= "<img src='images/greenicon.gif' width='20'>"; break;
case "YELLOW": $curStatusBox .= "<img src='images/yellowicon.gif' width='20'>"; break;
case "RED": $curStatusBox .= "<img src='images/redicon.gif' width='20'>"; break;
default: $curStatusBox .= "Status is not being frozen for this record";
}
} else { $curStatusBox .= "Status is not being frozen for this record"; }
unset ($resultFreezeStat);
} else { //1/6/2015: Not submitted - so shows real-time light status
if ((int)$chkQuestion==1) {
$curStatusBox .= "<img src='images/greenicon.gif' width='20'>";
//9/15/2014 Latest Audit Info
/* 12/11/2014 hide audit *** (if want to add it back, need to add fancybox script ***
$sqlchkAudit = "select AuditDate from far_audit where QuestionID=$thisQuestionID order by AuditDate Desc limit 1";
$resultA = mysql_query($sqlchkAudit, $dbconnection);
if (!$resultA) {
echo 'Could not run query [9]: ' . mysql_error();
exit;
}
$num_rowsA = mysql_num_rows($resultA);
if ($num_rowsA >0) { //if response is found
$rowA = mysql_fetch_array($resultA);
$AuditDateTemp = $rowA[0];
$AuditDateSplit = explode(" ", $AuditDateTemp);
$AuditDate = "<a class=\"fancybox\" href=\"audithistory.php?ID=" .$thisQuestionID. "\">" .$AuditDateSplit[0]. "</a>";
//$AuditDate = $AuditDateSplit[0];
} else {
$AuditDate = "N/A";
}
$curClauseInfo .= "<BR><BR>Last Audit: " . $AuditDate;
if($_SESSION['UserAccessLevel']=="FULLAUDIT") //9/15/2014 new access level AUDIT rights
$curClauseInfo .= "<BR>Auditor: <a class=\"fancybox\" href=\"audit.php?ID=" .$thisQuestionID. "\">Audit It</a></td>";
else
$curClauseInfo .= "</td>";
hide audit*** */
} elseif ($thisClauseType=="YELLOW") { //10/10/2014
$curStatusBox .= "<img src='images/yellowicon.gif' width='20'>";
$curClauseInfo .= "</td>";
} else {
$curStatusBox .= "<img src='images/redicon.gif' width='20'>";
$curClauseInfo .= "</td>";
}
}
$curStatusBox .= "</td>";
print "<tr>"; //9/15/2014 Print out new temp strings
print $curClauseInfo;
print $curStatusBox;
print $curStatusStr;
print "</tr>";
}
echo "</table></div>"; //10/15/2014 closing DIV, added document ready
?>
<SCRIPT type="text/javascript">
$(document).ready(function () {
$('#options table').floatThead({
//the pageTop is a global function i have here, it takes care of making the table float under my floated nav
scrollingTop: pageTop,
useAbsolutePositioning: false
});
});
</SCRIPT> <!--10/15/2014 END -->
<?php
}
?>
It's smaller and cleaner and the file_get_contents() can get the job done. But you always need to make sure you have the html of the page.

Related

call or create session variable in SUM

I am not very familiar with PHP or MySQL, but after researching here I have been able to learn and get very close to what I need and build my first sum query. I am trying to read the database and sum values based on several variables.
I need the reservation_pax from the reservations table where reservation_time is 8:00 where reservation_hidden = 0 and reservation_date is something. I can manually enter the date and it works. I am now trying to use a session code already in the script or find a way to to dynamically add based on selected date.
Here is the code I have working without the dynamic aspect or session.
$result = mysql_query("SELECT SUM(reservation_pax)
FROM reservations
WHERE reservation_time = '8:00:00'
AND reservation_date = '2014-10-27'
AND reservation_hidden ='0'") ;
if ($result === false) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($result)) {
echo $row['SUM(reservation_pax)'];
}
Here is the full code of the page where I entered the above addition. Can anyone help me figure out how to call the selected date rather than having to manually enter.
<!-- Begin reservation table data -->
<br/>
<table class="global resv-table-small" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<?php
echo "<td class='noprint'> </td>";
echo "<td>Time</td>";
echo "<td>Guests/Type</td>";
echo "<td>Name</td>";
echo "<td>Special Instructions/Notes</td>";
echo "<td class='noprint'>Table</td>";
echo "<td class='noprint'>Status</td>";
echo "<td class='noprint'>Created</td>";
echo "<td class='noprint'>Details/Delete</td>";
echo "</tr>";
// Clear reservation variable
$reservations ='';
if ($_SESSION['page'] == 1) {
$reservations = querySQL('all_reservations');
}else{
$reservations = querySQL('reservations');
}
// reset total counters
$tablesum = 0;
$guestsum = 0;
if ($reservations) {
//start printing out reservation grid
foreach($reservations as $row) {
// reservation ID
$id = $row->reservation_id;
$_SESSION['reservation_guest_name'] = $row->reservation_guest_name;
// check if reservation is tautologous
$tautologous = querySQL('tautologous');
echo "<tr id='res-".$id."'>";
echo "<td";
// daylight coloring
if ($row->reservation_time > $daylight_evening){
echo " class='evening noprint'";
}else if ($row->reservation_time > $daylight_noon){
echo " class='afternoon noprint'";
}else if ($row->reservation_time < $daylight_noon){
echo " class='morning noprint'";
}
echo " style='width:10px !important; padding:0px;'> </td>";
echo "<td id='tb_time'";
// reservation after maitre message
if ($row->reservation_timestamp > $maitre['maitre_timestamp'] && $maitre['maitre_comment_day']!='') {
echo " class='tautologous' title='"._sentence_13."' ";
}
echo ">";
echo "<strong>".formatTime($row->reservation_time,$general['timeformat'])."</strong></td>";
echo "<td id='tb_pax'><strong class='big'>".$row->reservation_pax."</strong> <span class='noprint'>";
printType($row->reservation_hotelguest_yn);
//echo "<img src='images/icons/user-silhouette.png' class='middle'/>";
echo "</span></td><td style='width:10%' id='tb_name'><span class='noprint'>".printTitle($row->reservation_title)."</span><strong> <a id='detlbuttontrigger' href='ajax/guest_detail.php?id=".$id."'";
// color guest name if tautologous
if($tautologous>1){echo" class='tautologous tipsy' title='"._tautologous_booking."'";}
echo ">".$row->reservation_guest_name."</a></strong>";
// old reservations symbol
if( (strtotime($row->reservation_timestamp) + $general['old_days']*86400) <= time() ){
echo "<img src='images/icons/clock-bolt.png' class='help tipsyold middle smicon' title='"._sentence_11."' />";
}
// recurring symbol
if ($row->repeat_id !=0) {
echo " <img src='images/icons/loop-alt.png' alt='"._recurring.
"' title='"._recurring."' class='tipsy' border='0' >";
}
echo"</td><td style='width:10%' id='tb_note'>";
if ($_SESSION['page'] == 1) {
echo $row->outlet_name;
}else{
echo $row->reservation_notes;
}
echo "</td>";
if($_SESSION['wait'] == 0){
echo "<td class='big tb_nr' style='width:85px;' id='tb_table'><img src='images/icons/table_II.png' class='tipsy leftside noprint' title='"._table."' /><div id='reservation_table-".$id."' class='inlineedit'>".$row->reservation_table."</div></td>";
}
echo "<td class='noprint'><div>";
getStatusList($id, $row->reservation_status);
echo "</div></td>";
echo "<td class='noprint'>";
echo "<small>".$row->reservation_booker_name." | ".humanize($row->reservation_timestamp)."</small>";
echo "</td>";
echo "<td class='noprint'>";
// MOVE BUTTON
// echo "<a href=''><img src='images/icons/arrow.png' alt='move' class='help' title='"._move_reservation_to."'/></a>";
// WAITLIST ALLOW BUTTON
if($_SESSION['wait'] == 1){
$leftspace = leftSpace(substr($row->reservation_time,0,5), $availability);
if($leftspace >= $row->reservation_pax && $_SESSION['outlet_max_tables']-$tbl_availability[substr($row->reservation_time,0,5)] >= 1){
echo" <a href='#' name='".$id."' class='alwbtn'><img src='images/icons/check-alt.png' name='".$id."' alt='"._allow."' class='help' title='"._allow."'/></a> ";
}
}
// EDIT/DETAIL BUTTON
echo "<a href='?p=102&resID=".$id."'><img src='images/icons/pen-fill.png' alt='"._detail."' class='help' title='"._detail."'/></a> ";
// DELETE BUTTON
if ( current_user_can( 'Reservation-Delete' ) && $q!=3 ){
echo"<a href='#modalsecurity' name='".$row->repeat_id."' id='".$id."' class='delbtn'>
<img src='images/icons/delete.png' alt='"._cancelled."' class='help' title='"._delete."'/></a>";
}
echo"</td></tr>";
$tablesum ++;
$guestsum += $row->reservation_pax;
}
}
?>
</tbody>
<tfoot>
<tr style="border:1px #000;">
<td class=" noprint"></td><td></td>
<td colspan="2" class="bold"><?php echo $guestsum;?> <?php echo _guest_summary;?></td>
<td></td>
<td colspan="2" class="bold"><?php echo $tablesum;?> <?php echo _tables_summary;?></td>
<td colspan="2" class="bold"><?php
$result = mysql_query("SELECT SUM(`reservation_pax`) FROM `reservations` WHERE `reservation_time` = '8:00:00' AND `reservation_date` = '{$_SESSION['selectedDate']}' AND `reservation_hidden` ='0'") ;
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($result))
{
echo $row['SUM(reservation_pax)'];
}
?>
<?php echo '/ 40 ', _guest_summary, ' -8:00 AM';?></td>
<td></td>
<?php
if($_SESSION['wait'] == 0){
//echo "<td></td>";
}
?>
</tr>
</tfoot>
</table>
<!-- End reservation table data -->
you can use alias field, as:
$result = mysql_query("SELECT SUM(reservation_pax) AS reserve_sum
FROM reservations WHERE reservation_time = '8:00:00'
AND reservation_date = '2014-10-27'
AND reservation_hidden ='0'"
) ;
....
and get access it as:
while($row = mysql_fetch_array($result))
{
echo $row['reserve_sum'];
}
$result = mysql_query("SELECT SUM(reservation_pax) FROM reservations WHERE reservation_time = '8:00:00' AND reservation_date = '{$_SESSION['selectedDate']}' AND reservation_hidden ='0'") ;
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($result))
{
echo $row['SUM(reservation_pax)'];
}
?>

Activating certain PHP code before a section of the page is Created

I am working with an HTML webpage connected to a database and using PHP. I have in a div at the top a variable that doesn't get properly set until some PHP later in the document. Is there a way to make the div build after the later PHP, but still be where it should be at the top of the page?
Here's the code that uses the variables
<div id="HeaderRight">
<div id="HeaderRight">
<?php
echo '<a href="../Cart/index.php" class="header">
<img src="../Images/shoppingcart.gif" height="18" width="127" border="0" align="ABSMIDDLE" /> Contains '.$_SESSION["num_items"].' Items</a>'
?>
</div>
Here's the code that sets the variables
<?php
echo '<TABLE WIDTH="100%" BGCOLOR="#FFFFFF" ALIGN = "RIGHT" BORDER = "1">';
echo '<TR BGCOLOR = "818996" HEIGHT = "25"><TD>Product</TD><TD>Availability</TD> <TD>Qty</TD><TD>Price</TD><TD>Total</TD></TR>';
$strTotalPrice = 0;
for ($i=0; $i<$_SESSION['num_products']; $i++) {
$strSQL = "SELECT * FROM products WHERE ProductCode = '".$_SESSION['cart'][$i]['name']."'";
$rsProd = mysql_query($strSQL)
or die($db_name . " : " . $strSQL . " : " . mysql_error());
$rowProd = mysql_fetch_array($rsProd);
$strSQLDetails = "SELECT * FROM pagedetails WHERE Category = '".$rowProd["Category"]."'";
$rsDetails = mysql_query($strSQLDetails)
or die($db_name . " : " . $strSQLDetails . " : " . mysql_error());
$rowDetails = mysql_fetch_array($rsDetails);
// End Of "Retrieve Desired Record Set"
echo ' <TR HEIGHT = "' .$rowProd["ThumbnailHeight"]. '" ><TD style="vertical-align:middle"><img src="../'.$rowProd["Department"].'/Images/'.$rowProd["ProductCode"].'_sm.jpg" align = "left" border="0" height = "'.$rowProd["ThumbnailHeight"].'" width="100" hspace="25" />
<br><a href = "../Products/Products.php?PageID='.$rowDetails["PageID"].'" >'.$rowProd["ProductName"].'</a>
</TD>';
$strAvailability = "";
$strQuantity = 0;
if($rowProd["Stock"] < $_SESSION["cart"][$i]["qty"]){
$strAvailability = "Only " .$rowProd["Stock"]. " in Stock, Quantity Changed";
$strQuantity = $rowProd["Stock"];
$_SESSION["cart"][$i]["qty"] = $rowProd["Stock"];
}
else{
$strAvailability = "In Stock";
$strQuantity = $_SESSION["cart"][$i]["qty"];
}
echo '<TD ALIGN = "center">'.$strAvailability.'</TD>';
echo '<TD ALIGN = "center">
<input type="text" name="txtQuantity" size="2" maxlength="2" value ='.$strQuantity.'>';
echo '<form action="index.php?=?product='.$rowProd["ProductCode"].'&quantity=1" method="post">
<input type="submit" name="submit" value="Update">
</form>
</TD>';
$strPrice = $rowProd["RegPrice"] * $strQuantity;
$strTotalPrice += $strPrice;
echo '<TD ALIGN = "center">$'.$rowProd["RegPrice"].'.00</TD>';
echo '<TD ALIGN = "center">$'.$strPrice.'.00</TD></TR>';
//echo '( <a href=index.php?product=' . $_SESSION['cart'][$i]['name'] . '&quantity=1>+</a> )';
}
As Rocket Hazmat points out, it is a good idea to run all of your PHP code before rendering the HTML. Without rewriting your current code, you can achieve this with some output buffering:
<?
// add this block
function firstDiv() {
ob_start();
?>
<div id="HeaderRight">
... <? echo $_SESSION["num_items"]; ?> ...
</div>
<?
// ... and this block
$_SESSION["firstDiv"] = ob_get_contents();
ob_end_clean();
} // end of firstDiv
?>
and the same with the rest of your page
<?
function restOfYourPage() {
ob_start();
?>
<TABLE> ... <? $_SESSION["num_items"] = 666; ?> ... </TABLE>
<?
$_SESSION["restOfYourPage"] = ob_get_contents();
ob_end_clean();
} // end of restOfYourPage
?>
Then you can run the php code in reverse order, but display it in normal order:
<?
restOfYourPage();
firstDiv();
echo $_SESSION["firstDiv"];
echo $_SESSION["restOfYourPage"];
?>

how to use get method in a session?

here is my code. actually i am displaying some data from mysql on the page and creating dynamic link.i want started a session with session_start() in the very begining of code before starting any code. i want to store the value of the link that is to be display on other pagepage..
page1.php
<a style="color:#F00; font-family:Arial, Helvetica, sans-serif; margin-left:33px; font-weight:bold">
No. of registered students:
</a>
<table border='1' align="center" style="font-size:14px" width="95%" cellspacing="3" class="db_table">
<tr class="db_table_tr" >
<th class="db_table_th" name="submit">USN</th>
</tr>
<?php
include('includes/login_connection.php');
$query = "select p.usn, p.name from personal_details p, course_codes c where p.usn = c.usn order by p.usn";
$run = mysql_query($query) or die($query."<br/><br/>".mysql_error());
$num = mysql_numrows($run);
echo $num;
while($row = mysql_fetch_assoc($run)){
echo "<tr>";
echo "<td>" . $row['usn'] . "" . "</td>";
echo "<td>" . $row['name'] . " </td>";
if(isset($_GET['submit'])){
$_SESSION['session_usn'] = $_GET['usn'];
}
}
echo "</tr>";
mysql_close($bd);
?>
</table>
page2.php
<?php
session_start();
if(isset($_SESSION['session_usn']))
{
$_POST['usn'] = $_SESSION['session_usn'];
echo $_POST['usn'];
}
?>
You need to provide a fall-back, in case the URL provided does not contain the proper variables in the $_GET section.
You have:
if(isset($_GET['submit'])){
$_SESSION['session_usn'] = $_GET['usn'];
}
You should do something else if $_GET['submit'] isn't set:
if(isset($_GET['submit'])){
$_SESSION['session_usn'] = $_GET['usn'];
} else {
$_SESSION['session_usn'] = "unset";
// or set a warning flag like "unset"
}
You should be feeding your php file a url like:
http://yoururl.com/page1.php?usn='333'
Where 333 is the value you want to store.

Ajax responsetext as a table output?

I'm not really familiar with Ajax Response - I have edited the PHP Ajax Search code from W3schools.com as follows :
<?php
require_once('connect_db.php');
$query = "select item_no from items";
$result = mysql_query($query);
$a = array();
while ($row = mysql_fetch_assoc($result)){
$a[] = $row['item_no'];
}
//get the q parameter from URL
$q=$_GET["q"];
//lookup all hints from array if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint=$a[$i];
}
else
{
$hint=$hint." , ".$a[$i];
}
}
}
}
// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint == "")
{
$response="No Suggestion";
}
else
{
$response=$hint;
}
//output the response
echo "<table border=1><tr><td>".$response."</td></tr></table>";
?>
The output of the above code works perfectly, but they are all listed like this (2L500BU , 2L500GO , 2L500NA , 2L500RD , 2L802CA , 2L802WH , 2L803GR , 2L804BE , 2L804BK , 2L804CO , 2L805BU , 2L806BE , 2L806GR ) - Those numbers are Item No in mysql table called items.
Now :
1) I want to output the response into table with <tr> for each like this
2l500BU
2L500GO
.
.
.
.
etc.
2) Do you think its possible to output all table records from Mysql based on the hint entered as follows :
$sql="SELECT * FROM items WHERE item_no = '".**$hint**."'";
$result = mysql_query($sql);
echo "<table align='center' cellpadding='3' cellspacing='3' width='800px' border='1' font style='font-family:arial;'>";
echo "
<tr align=center>
<th style=font-size:18px; bgcolor=#20c500>Item Number</th>
<th style=font-size:18px; bgcolor=#20c500>QTY</th>
<th style=font-size:18px; bgcolor=#20c500>Actual Price</th>
<th style=font-size:18px; bgcolor=#20c500>Selling Price</th>
<th style=font-size:18px; bgcolor=#20c500>Difference</th>
<th style=font-size:18px; bgcolor=#20c500>Date</th>
</tr>";
while($row = mysql_fetch_assoc($result)){
echo "<tr align=center bgcolor=#e3e3e3>";
echo "<td style='font-size:18px; font-weight:bold;'>" . strtoupper($row['item_no']) . "</td>";
echo "<td style='font-size:18px; font-weight:bold;'>" . $row['qty'] . "</td>";
echo "<td style='font-size:18px; font-weight:bold;'>" . $row['actual_price'] . " <font style=font-size:12px;>JD</font></td>";
echo "<td style='font-size:18px; font-weight:bold;'>" . $row['discount_price'] . " <font style=font-size:12px;>JD</font></td>";
echo "<td style='font-size:18px; font-weight:bold;'>" . $row['difference_price'] . " <font style=font-size:12px;>JD</font></td>";
echo "<td style='font-size:18px; font-weight:bold;'>" . date("d-m-Y",strtotime($row['date'])) . "</td>";
echo "</tr>";
}
echo "<table>";
If you're wanting to fetch items from a database and display a row for each of them, this is how you'd do it with jQuery.
Your PHP script:
<?php
$mysqli = new mysqli('localhost', 'user', 'password', 'database');
$sql = "SELECT item_no FROM items";
$res = $mysqli->query($sql);
while ($row = $res->fetch_assoc()) {
$rows[] = $row['item_no'];
}
header('Content-Type: application/json');
echo json_encode($rows);
?>
And your HTML with the table:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
<thead>
<tr>
<th scope="col">Item No.</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
<script src="js/lib/jquery.js"></script>
<script>
$(document).ready(function() {
$.getJSON('yourscript.php', function(items) {
$.each(items, function(i, item) {
$('tbody').append('<tr><td>' + item + '</td></tr>);
});
});
});
</script>
I've also used MySQLi (MySQL improved) rather than the standard mysql_ functions, as the mysql_ library is deprecated and you should be using either MySQLi or PDO now.

Add fields to event display form

I am using an open source calendar to display events, I am having a trouble to add extra fields to event display form. Could anyone please indicate where I need to add code so more fields can be displayed.
Please could anyone kindly help me.
Many Thanks.
Here is the code for displaying the events:
<?php
require("config.php");
require("./lang/lang." . LANGUAGE_CODE . ".php");
require("functions.php");
$auth = auth();
$id = $_GET['id'];
mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$sql = "SELECT d, m, y FROM " . DB_TABLE_PREFIX . "mssgs WHERE id=" . $id;
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$d = $row["d"];
$m = $row["m"];
$y = $row["y"];
$dateline = $lang['months'][$m-1] . " $d, $y";
$wday = date("w", mktime(0,0,0,$m,$d,$y));
writeHeader($m, $y, $dateline, $wday, $auth);
// display selected posting first
writePosting($id, $auth);
// give some space
echo '<img src="images/clear.gif" width="1" height="25" border="0"><br clear="all">';
// query for rest of this day's postings
$sql = "SELECT id, start_time FROM " . DB_TABLE_PREFIX . "mssgs ";
$sql .= "WHERE y = " . $y . " AND m = " . $m . " AND d = " . $d . " AND id != $id ";
$sql .= "ORDER BY start_time ASC";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result)) {
echo '<span class="display_header">' . $lang['otheritems'] . '</span>';
echo '<br clear="all"><img src="/images/clear.gif" width="1" height="3" border="0"><br clear="all">';
// display rest of this day's postings
while ($row = mysql_fetch_array($result)) {
writePosting($row[0], $auth);
echo '<img src="images/clear.gif" width="1" height="12" border="0"><br clear="all">';
}
}
echo "</body></html>";
function writeHeader($m, $y, $dateline, $wday, $auth)
{
global $lang;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>phpEventCalendar: Event Display</title>
<link rel="stylesheet" type="text/css" href="css/popwin.css">
<?php if ($auth) { ?>
<script language="JavaScript">
function deleteConfirm(eid) {
var msg = "<?php echo $lang['deleteconfirm'] ?>";
if (confirm(msg)) {
opener.location = "eventsubmit.php?flag=delete&id=" + eid + "&month=<?php echo $m ?>&year=<?php echo $y ?>";
window.setTimeout('window.close()', 1000);
} else {
return;
}
}
</script>
<?php } ?>
</head>
<body>
<!-- selected date -->
<table cellspadding="0" cellspacing="0" border="0" width="300" bgcolor="#CCFFCC">
<tr>
<td bgcolor="#CCFFCC"><span bgcolor="#CCFFCC" class="display_header"><?php echo $dateline ?></span></td>
<td bgcolor="#CCFFCC" align="right"><span class="display_header"><?php echo $lang['days'][$wday] ?></span></td>
</tr>
</table>
<img src="images/clear.gif" width="1" height="3" border="0"><br clear="all">
<?php
}
function writePosting($id, $auth)
{
global $lang;
mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$sql = "SELECT y, m, d, title, text, start_time, end_time, ";
$sql .= DB_TABLE_PREFIX . "users.uid, fname, lname, ";
if (TIME_DISPLAY_FORMAT == "12hr") {
$sql .= "TIME_FORMAT(start_time, '%l:%i%p') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%l:%i%p') AS etime ";
} elseif (TIME_DISPLAY_FORMAT == "24hr") {
$sql .= "TIME_FORMAT(start_time, '%H:%i') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%H:%i') AS etime ";
} else {
echo "Bad time display format, check your configuration file.";
}
$sql .= "FROM " . DB_TABLE_PREFIX . "mssgs ";
$sql .= "LEFT JOIN " . DB_TABLE_PREFIX . "users ";
$sql .= "ON (" . DB_TABLE_PREFIX . "mssgs.uid = " . DB_TABLE_PREFIX . "users.uid) ";
$sql .= "WHERE id = " . $id;
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$title = stripslashes($row["title"]);
$body = stripslashes(str_replace("\n", "<br />", $row["text"]));
$postedby = $lang['postedby'] . ": " . $row['fname'] . " " . $row['lname'];
if (!($row["start_time"] == "55:55:55" && $row["end_time"] == "55:55:55")) {
if ($row["start_time"] == "55:55:55")
$starttime = "- -";
else
$starttime = $row["stime"];
if ($row["end_time"] == "55:55:55")
$endtime = "- -";
else
$endtime = $row["etime"];
$timestr = "$starttime - $endtime";
} else {
$timestr = "";
}
if ($auth == 2 || ($auth != 0 && $_SESSION['authdata']['uid'] == $row['uid'])) {
$editstr = "<span class=\"display_edit\">";
$editstr .= "[edit] ";
$editstr .= "[delete] </span>";
} else {
$editstr = "";
}
?>
<table cellspacing="0" cellpadding="0" border="0" width="300" bgcolor="#CCFFCC">
<tr><td bgcolor="#000000">
<table cellspacing="1" cellpadding="1" border="0" width="100%">
<tr>
<td class="display_title_bg" bgcolor="#CCFFCC"><table bgcolor="#CCFFCC" cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td bgcolor="#CCFFCC" width="100%"><span class="display_title"> <?php echo $title ?></span></td>
<td bgcolor="#CCFFCC"><img src="images/clear.gif" width="20" height="1" border="0"></td>
<td bgcolor="#CCFFCC" align="right" nowrap="yes"><span class="display_title"><?php echo $timestr ?> </span></td>
</tr></table></td>
</tr>
<tr bgcolor="#CCFFCC"><td class="display_txt_bg" bgcolor="#CCFFCC">
<table cellspacing="1" cellpadding="1" border="0" width="100%" bgcolor="#CCFFCC">
<tr bgcolor="#CCFFCC">
<td bgcolor="#CCFFCC"><span class="display_txt"><?php echo $body ?></span></td>
</tr>
<tr bgcolor="#CCFFCC">
<td bgcolor="#CCFFCC"align="right"><span class="display_user"><?php echo $postedby ?></td>
</tr>
<tr bgcolor="#CCFFCC">
<td align="right" bgcolor="#CCFFCC"><?php echo $editstr ?></td>
</tr>
</table>
</td></tr>
</table>
</td></tr></table>
<?php
}
?>
To the best of my understanding writePosting function does most of the job and you need to enhance it to display more info about current event.
I've added a new table row at the end of this code sample to illustrate the idea.
<tr bgcolor="#CCFFCC">
<td bgcolor="#CCFFCC"><span class="display_txt"><?php echo $body ?></span></td>
</tr>
<tr bgcolor="#CCFFCC">
<td bgcolor="#CCFFCC"align="right"><span class="display_user"><?php echo $postedby ?></td>
</tr>
<tr bgcolor="#CCFFCC">
<td align="right" bgcolor="#CCFFCC"><?php echo $editstr ?></td>
</tr>
<tr bgcolor="#CCFFCC">
<td align="right" bgcolor="#CCFFCC"><?php echo "some extra info" ?></td>
</tr>

Categories