I want to print binary tree (Below Image) in php from database value
And above is my database table structure
Here is what I tried, In this code I want to display binary tree of user id PX100
<?php
include 'db_connect.php';
$user_id = 'PX100';
$select_right_tree = $con->prepare("SELECT * FROM tbl_user_postion WHERE user_id=:user_id");
$select_right_tree->bindParam(":user_id", $user_id);
$select_right_tree->execute();
$fetch_right_tree = $select_right_tree->fetch(PDO::FETCH_ASSOC);
$ex_pos_right = $fetch_right_tree['pos_right'];
$ex_pos_left = $fetch_right_tree['pos_left'];
function right_part($pos_right) {
if(!empty($pos_right)) {
$select_left_tree = $con->prepare("SELECT pos_right, pos_left FROM tbl_user_postion WHERE user_id=:user_id");
$select_left_tree->bindParam(":user_id", $pos_right);
$select_left_tree->execute();
$fetch_left_tree = $select_left_tree->fetch(PDO::FETCH_ASSOC);
$user_right = $fetch_left_tree['pos_right'];
$user_left = $fetch_left_tree['pos_left'];
return array($user_right, $user_left);
if(!empty($user_right)) {
right_part($user_right);
}
if(!empty($user_left)) {
left_part($user_left);
}
}
}
function left_part($pos_left) {
if(!empty($pos_left)) {
$select_left_tree = $con->prepare("SELECT pos_right, pos_left FROM tbl_user_postion WHERE user_id=:user_id");
$select_left_tree->bindParam(":user_id", $pos_left);
$select_left_tree->execute();
$fetch_left_tree = $select_left_tree->fetch(PDO::FETCH_ASSOC);
$user_right = $fetch_left_tree['pos_right'];
$user_left = $fetch_left_tree['pos_left'];
return array($user_right, $user_left);
if(!empty($user_left)) {
left_part($user_left);
}
if(!empty($user_right)) {
right_part($user_right);
}
}
}
?>
<div class="tree">
<ul>
<li>
<img src="image/user.png" ><br/><?php echo $user_id; ?>
<ul>
<li>
<img src="image/user.png"><br/><?php echo $ex_pos_right; ?>
<?php
if(!empty($ex_pos_right))
{
list($pos_right1, $pos_left1) = right_part($ex_pos_right);
?>
<ul>
<li> <img src="image/user.png"><br/><?php echo $pos_right1; ?> </li>
<li> <img src="image/user.png"><br/><?php echo $pos_left1; ?> </li>
</ul>
<?php
}
?>
</li>
<li>
<img src="image/user.png"><br/><?php echo $ex_pos_left; ?>
<?php
if(!empty($ex_pos_left))
{
list($pos_right2, $pos_left2) = left_part($ex_pos_left);
?>
<ul>
<li> <img src="image/user.png"><br/><?php echo $pos_right2; ?> </li>
<li> <img src="image/user.png"><br/><?php echo $pos_left2; ?> </li>
</ul>
<?php
}
?>
</li>
</ul>
</li>
</ul>
</div>
Output of the above code is Here,
From database table, PX103 is a parent of PX108 and PX110, PX105 is parent of PX107 and PX111 , PX106 is parent of PX109. But PX108, PX110, PX107, PX111 and PX109 are not displaying in tree.
Please help me to sort out this problem.
Thankyou.
<table class="table table-bordered table-striped">
<tr>
<td width="950" >
<?php $m_id=NULL;$m_id=$_SESSION['id'];
$width=580;
for($lopp=0;$lopp<=3;$lopp++){
$tree=mysqli_query($sql,"select * from tree where distributer_id='".$m_id."'");
$m_id_fetch=mysqli_fetch_assoc($tree);
$left_m_id=$riggt_m_id="";
$tree_detaila=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id."'");
if(!$tree_detaila) print mysqli_error($sql);
$detail=mysqli_fetch_assoc($tree_detaila);
if(!empty($m_id_fetch['pos_left'])) $left_m_id=$m_id_fetch['pos_left'];if(!empty($m_id_fetch['pos_right'])) $riggt_m_id=$m_id_fetch['pos_right'];
?> <table class="table-responsive" width="850" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top" align="center"> <table class="table-responsive" width="<?php print $width; ?>" border="0" align="<?php if(!empty($m_id_fetch['pos_left']) && $lopp>0) print "left"; elseif(!empty($m_id_fetch['pos_right']) && $lopp>0) print "right" ?> " cellpadding="0" cellspacing="0">
<?php if($lopp==0) { ?> <tr>
<td width="<?php print $width; ?>" align="center"> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" />
</td>
</tr>
<tr>
<td align="center"><?php print strtoupper($detail['Name']); ?></td>
</tr>
<tr>
<td align="center"><?php print $detail['yo_id']; ?></td>
</tr><?php } else { print ' <tr>
<td colspan="2" align="left"></td>
</tr>'; } ?>
<tr>
<td align="center">
<tr>
<td colspan="2" align="<?php if(!empty($m_id_fetch['pos_left']) && $lopp>0) print "left"; elseif(!empty($m_id_fetch['pos_right']) && $lopp>0) print "right" ?>"><img src="img/p.png" width="<?php print $width=$width-90; ?> " height="5" /></td>
</tr>
<?php
if($left_m_id!="" )
{
$tree_detaila_l=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id_fetch['pos_left']."'");
$detail_l=mysqli_fetch_assoc($tree_detaila_l);
}
if($riggt_m_id!="")
{
$tree_detaila_r=mysqli_query($sql,"select Name,yo_id from registration where yo_id='".$m_id_fetch['pos_right']."'");
$detail_r=mysqli_fetch_assoc($tree_detaila_r);
}
?>
<tr>
<?php if($left_m_id!="" ){ ?> <td align="left">
<a href='#' class='tt'> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" /> </a></td><?php } ?>
<?php if($riggt_m_id!="" ){ ?> <td align="right">
<a href='#' class='tt'> <img src="dashboard/images/user.jpg" width="45" height="50" class="img-circle" /> </a></td><?php } ?>
</tr>
<tr>
<?php if($left_m_id!="") { ?><td align=" left"><?php print $detail_l['Name']; ?></td><?php } ?> <?php if($riggt_m_id!="") { ?><td align=" right"><?php print $detail_r['Name']; ?></td><?php } ?>
</tr>
<tr>
<?php if($left_m_id!="") { ?><td align=" left">
<?php print $detail_l['yo_id']; ?>
</td><?php } ?> <?php if($riggt_m_id!="") { ?><td align=" right">
<?php print $detail_r['yo_id']; ?>
</td><?php } ?>
</tr>
</table></td>
</tr>
</table><?php $width=$width-100;$m_id=$m_id_fetch['pos_right']; } ?>
</td>
</tr>
</table>`enter code here`
Related
image link
Good day everyone i would like to ask if there is someone had a idea on how to make that specific column a link so that the user can download that pdf file.
This my Datatable
<table id="example" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
<tr>
<th class="text-center align-middle">Control Number</th>
<th class="text-center align-middle">Attached Form</th>
<th class="text-center align-middle">P.R. Date.</th>
<th class="text-center align-middle">ABC/PR Amount.</th>
<th class="text-center align-middle">File</th>
</tr>
</thead>
<tbody>
<?php
if($logs){
foreach ($logs as $log){
?>
<tr>
<td class="<?php
if (empty($log->control_number)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->control_number)) {
echo $log->control_number;
}
?>
</td>
<td class="<?php
if (empty($log->category)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->category)) {
echo $log->category;
}
?>
</td>
<td class="<?php
if (empty($log->pr_date)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->pr_date)) {
echo date("m/d/Y", strtotime($log->pr_date));
}
?>
</td>
<td class="<?php
if (empty($log->approve_budget )) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->approve_budget )) {
echo $log->approve_budget ;
}
?>
</td>
//Here is the column that i want to be a link to be downloaded
<td class="<?php
if (empty($log->file)) {
echo "noactioncell";
}
else
{
echo "donecell";
}
?> text-center align-middle" >
<?php
if (!empty($log->file )) {
echo $log->file ;
}
?>
</td>
////////////////////////////////////////////////////////////////////////
</tr>
<?php
}
}
?>
</tbody>
</table>
just create an anchor link
<?php
if (!empty($log->file )) {
echo '<a href="'.$log->file.'" target="_blank" >'.$log->file.'</a>';
}
I have a basic admin panel where I can see all the vendors and all the products that have been added. In the vendors page, I want to add a link which when clicked on would display/add/edit only the products for that vendor. Any leads on how this can be done?
************ EDIT **************
This is how my products page looks like. This page displays all the products.
<?php
$sno=$pagination->getLimit() + 1;
$sql2 = $sql1." limit " . $pagination->getLimit() . ", ". $rowsperpage;
$res2 = #mysql_query($sql2, $connection) or die("failed");
$i = 1;
$c=1;
$k=0;
while($res=mysql_fetch_array($res2))
{
?>
<tr <?php if($k==0) { echo 'class=""'; } else { echo 'class="row_color"'; } ?> id="row<?php echo $i;?>">
<td class="table_text"><?php echo $sno; ?>.</td>
<td class="table_text" style="line-height:12pt;">
<?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo $res['Name']; ?></span>
<?php
}
else
{
?>
<?php echo $res['Name']; ?>
<?php
}
?>
</td>
<td class="table_text" style="line-height:12pt;">
<?php
$rest_name = mysql_query("SELECT * FROM `restaurants` WHERE `RestID`='$res[RestID]'");
$res_fet = mysql_fetch_array($rest_name);
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo $res_fet['Name']; ?></span>
<?php
}
else
{
?>
<?php echo $res_fet['Name']; ?>
<?php
}
?>
</td>
<td class="table_text" style="line-height:12pt;"> <?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo date('d-m-Y',strtotime($res['StartDate']));?></span>
<?php
}
else
{
?>
<?php echo date('d-m-Y',strtotime($res['StartDate']));?>
<?php
}
?> </td>
<td class="table_text" style="line-height:12pt;"><?php
if($res['off_status']=='N')
{
?>
<span style="padding-left: 0px;font-weight:bold;color:#E8E8E8;"><?php echo date('d-m-Y',strtotime($res['ExpiryDate']));?></span>
<?php
}
else
{
?>
<?php echo date('d-m-Y',strtotime($res['ExpiryDate']));?>
<?php
}
?></td>
<td class="table_text"><table width="68" height="68" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffebc1">
<tr>
<td align="center"><?php
if($res['Image'] != "")
{
?>
<img src="../images/offers/thumb/<?php echo $res['Image']; ?>" border="0" />
<?php
}
else
{
?>
<img src="../images/no_image.jpg" width="88" height="76" border="0" />
<?php
}
?> </td>
</tr>
</table></td>
<td align="center" class="table_text"><img src="images/icon/level.png" width="47" height="43" border="0" /></td>
<td align="center" class="table_text"><img src="images/link.png" alt="" width="47" height="43" border="0" /></td>
<td align="center" class="table_text"><img src="images/icon/edit_icon.gif" width="16" height="15" border="0" /></td>
<td align="center" class="table_text"><img src="images/icon/view_icon.gif" width="16" height="16" border="0" /></td>
<?php
if($res['off_status']=='Y')
{
?>
<td align="center" class="table_text">Active</td>
<?php
}
else
{
?>
<td width="15%" align="center" class="table_text"> Inactive</td>
<?php
}
?>
<td width="14%" align="center" class="table_text"><img src="images/del.png" width="16" height="15" border="0" /></td>
</tr>
<?php
$c++;
$i++;
$k++;
$sno++;
if($k==2)
{
$k=0;
}
}
?>
<input type="hidden" name="acount" id="acount" value="<?php echo $i-1; ?>">
</table>
This is how I've called the link to the above mentioned page:
<?php
$sel=mysql_query("select * from offers where OfferID='".$id."'") or die(mysql_error());
$fet=mysql_fetch_array($sel);
$rest=mysql_query("select * from restaurants where RestID='".$fet['RestID']."'") or die(mysql_error());
$restfet=mysql_fetch_array($rest);
$dd= $fet['Links'];
$rest_id=$fet['RestID'];
$sql_mlink=mysql_query("select * from offers where off_status='Y' and OfferID!='".$id."' and RestID='".$rest_id."' order by OfferID asc") or die(mysql_error());
$sql_query = mysql_query("SELECT * FROM offers where RestID='".$res['RestID']."'");
$row = mysql_fetch_array($sql_query);
//$res_count=mysql_num_rows($row);
$sy = mysql_query("SELECT * FROM offers where RestID='".$res['RestID']."' and status='Y'");
$res_count=mysql_num_rows($sy);
$rw = mysql_fetch_array($sy);
?>
<td class="table_text">
Menu
</td>
You should be able to achieve this quite easily using php get and adjusting you're SQL slightly.
Add the vendor number/escaped name to the end of links to this page... e.g.:
<a href='this-page.php?vendor=vendor-1'>vendor 1</a>
Then at the beginning of the page check if there was a vendor set and if so, create some extra sql for the end of your statements. If not leave the extra sql variable blank so nothing is added:
if(!empty($_GET['vendor']))
{
$extra_sql = " AND vendor = ".$_GET['vendor'];
}
else
{
$extra_sql = "";
}
Then add the $extra_sql variable to the end of your existing SQL:
$rest=mysql_query("select * from restaurants where RestID='".$fet['RestID']."'".$extra_sql) or die(mysql_error());
I'm trying to solv this issue. I have this php code.
<?php
if (count($Modulos)>0){
for ($x=0; $x<count($Modulos); $x++){
// SOME CODE, to define variables
$controller = 1;
require_once "../controller/moduloController.php";
for ($z=0; $z<count($ActividadesMOD); $z++){
echo $ActividadesMOD[$z]['actividad']. "<br/>";
}
?>
<tr height="35">
<td align="center"> <strong><?php echo $modulo;?> </strong></td>
<td align="center"> <?php echo $encargado[0];?> </td>
<td align="center" valign="middle"> <?php echo $deadline;?>
<a href="javascript:VerDeadline(<?php echo $idmodulo;?>, '4','<?php echo $deadline;?>', '<?php echo $modulo;?>', '<?php echo $finalizado;?>')" onClick="">
<img src="../img/zoom-icon.png" width="17" height="17" align="absbottom">
</a>
</td>
<td align="center"> <strong> <?php echo $avance . " %";?></strong></td>
<td align="center"> <img src="<?php echo $img;?>" width="28" height="15" title="<?php echo $ttl;?>" /> </td>
<td width="7%" align="center"> </td>
</tr>
<?php }
} else { ?>
<tr height="30" style="font-size:11px" >
<td align="center" colspan="5"> [ NO HAY REGISTROS ] </td>
</tr>
<?php } ?>
Result:
Now, each MODULO has ACTIVIDADES (activities) that i need to show below it.
In the image above, it displays the ACTIVITIES from the MODULO 1 and not the other ones.
Taking the example from other page, should be like this:
I got it !!
Changing the require_once for include.
The result with some css:
Greetings.
I'm trying to display two (2) columns instead of my current one (1) column.
My example here:
http://freeskateboardsticker.com/news/authors.php
I have rewritten the script many times, but I cannot seem to get the rows and columns to display correctly and still keep the pagination intact.
Below is my script:
<?php include_once(realpath("templates/top.php")); ?>
<?php include_once(realpath("templates/$templates/mid1.php")); ?>
<?php
$page = #$_GET["page"];
$start = #$_GET["start"];
if (!is_numeric($page) || $page < 1)
$page = 1;
if ($page == 1)
$start = 0;
else
$start = ($page * $authorsPerPage) - $authorsPerPage;
$aResult = mysql_query("select pk_alId, alEmail, alFName, alLName, alBio, alDateJoined from tbl_AdminLogins order by alFName, alLName limit $start, $authorsPerPage");
$numRows = mysql_num_rows(mysql_query("select pk_alId from tbl_AdminLogins order by alFName, alLName"));
if ($numRows > 0) {
?>
<!-- Start Authors -->
<div align="center">
<center>
<TABLE WIDTH="86%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD WIDTH="100%" HEIGHT="20" COLSPAN="2" ALIGN="right" class="BodyText" VALIGN="top"><FONT COLOR="#0B75AF"> <?PHP
if ($page > 1)
$nav .= "<a href='authors.php?page=" . ($page - 1) . "'><span class='Link1'><u>« Prev</u></span></a> | ";
for ($i = 1; $i <= ceil($numRows / $authorsPerPage); $i++)
if ($i == $page)
$nav .= "<a href='authors.php?page=$i'><span class='Link4'><b>$i</b></span></a> | ";
else
$nav .= "<a href='authors.php?page=$i'><span class='Link1'>$i</span></a> | ";
if (($start + $authorsPerPage) < $numRows && $numRows > 0)
$nav .= "<a href='authors.php?page=" . ($page + 1) . "'><span class='Link1'><u>Next »</u></span></a>";
if (substr(strrev($nav), 0, 2) == " |")
$nav = substr($nav, 0, strlen($nav) - 2);
echo $nav . "<br> ";
?></FONT>
</TD>
</TR>
</TABLE>
<?php while ($aRow = mysql_fetch_array($aResult)) { ?>
<div align="center"><center>
<TABLE WIDTH="720" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR>
<TD WIDTH="185"> <?php if ($showAuthorImages) { ?><img src="imageview.php?what=getAuthorPic&authorId=<?php echo $aRow["pk_alId"]; ?>"> <?php } ?></TD>
<TD WIDTH="5" VALIGN="top"> </TD>
<TD WIDTH="530" VALIGN="MIDDLE"><SPAN CLASS="BodyHeading1"><?PHP echo $aRow["alFName"]; ?></SPAN>
<BR><span class="Text1"><?php echo $aRow["alBio"]; ?></span><br></TD>
</TR>
<TR>
<TD COLSPAN="3"> </TD>
</TR>
</TABLE>
</center></div>
<?php } ?>
<div align="center">
<center>
<table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="20" colspan="2" align="right" valign="top">
<SPAN CLASS="Text4"><?php echo $nav . "<br> "; ?></SPAN>
<br>
</td>
</tr>
</table>
</center>
</div>
<!-- End Authors -->
<?php
} else {
// No authors found in the database
?>
<!-- StartAuthors -->
<div align="center">
<center>
<table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="2" bgcolor="#FFFFFF" height="21">
<span class="BodyHeading">
<br>No Authors Found
</span>
<span class="Text1">
<br><br>
No authors were found in the database. Please use
the link below to return to our home page.
<br><br>
</span>
Return Home
</td>
</tr>
</table>
</center>
</div>
<!-- End Authors -->
<?php
}
?>
Do not use font tag, it is deprecated
br /> not br>
If you are writing then write all other tags also in lower case
Use some MySQLi library (PDO etc)
Do not put center and div with align center tag into while cycle
Build table rows in while cycle, not one table per one author (table beginning before while, table ending after while cycle, inside while leave onl tr/td generation)
Move your loop inside the table, to create a new row per iteration, not a new table:
<div align="center">
<center>
<TABLE WIDTH="720" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<?php while ($aRow = mysql_fetch_array($aResult)) { ?>
<TR>
<TD WIDTH="185"> <?php if ($showAuthorImages) { ?><img src="imageview.php?what=getAuthorPic&authorId=<?php echo $aRow["pk_alId"]; ?>"> <?php } ?></TD>
<TD WIDTH="5" VALIGN="top"> </TD>
<TD WIDTH="530" VALIGN="MIDDLE"><SPAN CLASS="BodyHeading1"><?PHP echo $aRow["alFName"]; ?></SPAN>
<BR><span class="Text1"><?php echo $aRow["alBio"]; ?></span><br></TD>
</TR>
<TR>
<TD COLSPAN="3"> </TD>
</TR>
<?php } ?>
</TABLE>
</center>
</div>
is this a good way of doing it? or should i use a date time stamp with seconds rather?
while i am on a page, the new message must come through without me refreshing the page
my code is written in php:
<div id='div_longgray_gradient2'>
<div id='div_float_img'>
<table width='96%' border='0'>
<tr>
<td rowspan='2' width='40px' align='left'>
<img src='/images/rainbow/arrow.png'>
</td>
<td align='left'>
<span class='spn_big_black_rbc'>MESSAGES</span>
</td>
</tr>
<tr>
<td align='left'>
<span class='spn_med_lightblue_rbc'>Inbox</span>
</td>
<td align='left'>
</td>
</tr>
</table>
<br/>
<br/>
<table width='80%' align='center'>
<tr>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>Received</span></td>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>Message</span></td>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>From</span></td>
</tr>
<?php
$cursor = $pager->getFirstIndice();
foreach ($pager->getResults() as $msg)
{
$has_freechat = false;
//changed id to withid here
$freechat_req_link="profiles/confirmfreechat?withid=".$msg->getRcProfileTableRelatedByProfileIdFrom()->getId();
$freechat_req_link=link_to('Freechat',$freechat_req_link,'class=link_small_dark');
$cc = sizeof ($fc_records);
for($i = 0; $i < $cc; $i++)
{
if($fc_records[$i]->getProfileIdWith() == $msg->getProfileIdFrom())
{
$has_freechat = true;
break;
}
}
$unique_code_from = $msg->getRcProfileTableRelatedByProfileIdFrom()->getUniqueCode();
$block_url = link_to('Block User',"blocklist/block?unqiue_code=$unique_code_from",'class=link_medium_blue');
echo "<tr>";
$date = add_date($msg->getCreatedAt(),$hr=2);
echo "<td class='td_show_contact_item' align='left'>".$date."</td>";
$opened_once = $msg->getOpenedOnce();
if($opened_once >= 1)
{
echo "<td class='td_show_contact_item' align='left'>".link_to($msg->getSubject(), 'messagebox/read?cursor='.$cursor,'class=link_medium_blue')."</td>";
}
else
{ ?>
<td align='left'>
<a href="<?php echo url_for('messagebox/read?cursor=').$cursor ?>" style='color:#ff0000 !important' class='spn_small_red_rbc'><?php echo $msg->getSubject();?></a>
</td>
<?php
}
echo "<td class='td_show_contact_item' align='left'>".$unique_code_from." ( $block_url )</td>";
echo "</tr>";
++$cursor;
}
function add_date($givendate,$hr=2)
{
$cd = strtotime($givendate);
$newdate = date('Y-m-d H:i:s', mktime(date('h',$cd)+$hr, date('i',$cd), date('s',$cd), date('m',$cd), date('d',$cd), date('Y',$cd)));
return $newdate;
}
?>
</table>
<br/>
Displaying results <?php echo $pager->getFirstIndice() ?> to <?php echo $pager->getLastIndice() ?>.
<br/>
<?php if ($pager->haveToPaginate()): ?>
<?php echo link_to('«', 'messagebox/list?page='.$pager->getFirstPage()) ?>
<?php echo link_to('<', 'messagebox/list?page='.$pager->getPreviousPage()) ?>
<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<?php echo ($page == $pager->getPage()) ? $page : link_to($page, 'messagebox/list?page='.$page) ?>
<?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif ?>
<?php endforeach ?>
<?php echo link_to('>', 'messagebox/list?page='.$pager->getNextPage()) ?>
<?php echo link_to('»', 'messagebox/list?page='.$pager->getLastPage()) ?>
<?php endif ?>
<table width='96%' border='0'>
<tr>
<td rowspan='2' width='40px' align='left'>
<img src='/images/rainbow/arrow.png'>
</td>
<td align='left'>
<span class='spn_big_black_rbc'></span>
</td>
</tr>
<tr>
<td align='left'>
<span class='spn_med_lightblue_rbc'>Sent Items</span>
</td>
</tr>
</table>
<br/>
<br/>
<table width='80%' align='center'>
<tr>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>Sent</span></td>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>Message</span></td>
<td class='td_show_contact_heading' align='left'><span class='spn_med_lightblue_rbc'>To</span></td>
</tr>
<?php
$cursor2 = $pager2->getFirstIndice();
$br = sizeof ($block_records);
foreach ($pager2->getResults() as $item)
{
$link = link_to('Delete',"messagebox/deleteSentmsg?mid=".$item->getId(),'class=link_medium_blue');
$id = $item->getRcProfileTableRelatedByProfileIdTo()->getId();
?>
<tr>
<td class='td_show_contact_item' width='15%' align='left'><?php echo $date = add_date($item->getCreatedAt(),$hr=2); ?></td>
<td class='td_show_contact_item' width='45%' align='left'><?php echo $item->getMessage()?></td>
<td class='td_show_contact_item' width='25%' align='left'><?php echo $item->getRcProfileTableRelatedByProfileIdTo()->getUniqueCode()." ".$link;?></td>
</tr>
<?php
++$cursor2;
}
?>
</table>
<br/>
Displaying results <?php echo $pager2->getFirstIndice(); ?> to <?php echo $pager2->getLastIndice(); ?>.
<br/>
<?php if ($pager2->haveToPaginate()): ?>
<?php echo link_to('«', 'messagebox/list?page2='.$pager2->getFirstPage(),'class=link_big_dark') ?>
<?php echo link_to('<', 'messagebox/list?page2='.$pager2->getPreviousPage(),'class=link_big_dark') ?>
<?php $links = $pager2->getLinks(); foreach ($links as $page2): ?>
<?php echo ($page2 == $pager2->getPage()) ? $page2 : link_to($page2, 'messagebox/list?page2='.$page2,'class=link_big_dark') ?>
<?php if ($page2 != $pager2->getCurrentMaxLink()): ?> - <?php endif ?>
<?php endforeach ?>
<?php echo link_to('>', 'messagebox/list?page2='.$pager2->getNextPage(),'class=link_big_dark') ?>
<?php echo link_to('»', 'messagebox/list?page2='.$pager2->getLastPage(),'class=link_big_dark') ?>
<?php endif ?>
</div>
</div>
can anyone give some advise please?
i have no ajax/JS here so dont know how i would incorporate it
PHP is a server side language and will not update a page once it has been fetched by the browser. To do this you will need to use a combination of server side and client side scripts.
One way of making your page update it's content is to use AJAX (http://api.jquery.com/jQuery.ajax/) combined with a timer (setInterval() and setTimeout()) to query a PHP script and check for updates every x seconds. The updates can then be added to the page when they are available using JavaScript / jQuery.