unexpected T_CONSTANT_ENCAPSED_STRING - php

Am using CakePHP running on XAMPP Server with PHP 5.3.5 i keep getting the error message
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Line 38
Line 38 is 'Published',
The Code
<div id="center_content">
<h2>Post Listings</h2>
<p>Here is a list of existing posts</p>
<div>
</div>
<?php
if (isset($posts) && is_array($posts))
{
?>
<table>
<tr>
<td>
<b>ID</b>
</td>
<td>
<b>title</b>
</td>
<td>
<b>content</b>
</td>
<td>
<b>Last Modified</b>
</td>
<td>
<b>published<b>
</td>
<td colspan="2"><b> Action</b></td>
</tr>
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id'];?></td>
<td><?php echo $post['Post']['title'];?></td>
<td><?php echo $post['Post']['content'];?></td>
<td><?php echo $post['Post']['modified'];?></td>
<td>
<?php echo $html->link(ife(
$post['Post']['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable').'/'.$post['Post']['id']
);
?>
</td>
<td>
<?php echo $html->link(
'Edit',
'/posts/edit'.$post['Post']['id']);?>
</td>
<td>
<?php echo $html->link(
'Delete',
'/posts/delete/'.$post['Post']['id']);?>
</td>
</tr>
<? endforeach; ?>
<?php
if (sizeof($posts) == 0) {
?>
<tr style= "background-color:#cccccc;">
<td colspan="6">
<span style="font-size: 17px;">
No post found.
</span>
</td>
</tr>
<?php
}
?>
</table>
<br/>
<?php
}
?>
</div>
Thats all, Note am running the app with PHP 5.3.5 using CakePHP MVC Framework

Change it from
<?php echo $html->link(ife(
'$post['Post']['published'] == 1',
'Published',
'Unpublished'),
'/posts/'.ife('$post'['Post']['published'] == 1',
'disabled','enable').'/'.$post['Post']['id']
);
?>
to
<?php echo $html->link(ife(
$post['Post']['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable).'/'.$post['Post']['id']
);
?>
You just needed to remove the single quote right before $post

Try and make it a bit more readable:
$isPublished = ($post['Post']['published'] == 1) ? true : false;
echo $html->link(
ife($isPublished, 'Published','Unpublished'),
'/posts/' . ife($isPublished, 'disabled', 'enable') . '/' . $post['Post']['id']
);

$post['Post']['published'] == '1',

This works for me... You had an old style php tag and had single quotes in the wrong spots.
I'm not sure what "ife" is, most likely an if statement gone wrong ?
<div id="center_content">
<h2>Post Listings</h2>
<p>Here is a list of existing posts</p>
<div>
</div>
<?php
if (isset($posts) && is_array($posts))
{
?>
<table>
<tr>
<td>
<b>ID</b>
</td>
<td>
<b>title</b>
</td>
<td>
<b>content</b>
</td>
<td>
<b>Last Modified</b>
</td>
<td>
<b>published<b>
</td>
<td colspan="2"><b> Action</b></td>
</tr>
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id'];?></td>
<td><?php echo $post['Post']['title'];?></td>
<td><?php echo $post['Post']['content'];?></td>
<td><?php echo $post['Post']['modified'];?></td>
<td>
<?php echo $html->link(
($post['Post']['published'] == 1 ? 'Published' : 'Unpublished'),
'/posts/' .
($post['Post']['published'] == 1 ? 'disabled' : 'enabled') .
'/' . $post['Post']['id']
);
?>
</td>
<td>
<?php echo $html->link(
'Edit',
'/posts/edit'.$post['Post']['id']);?>
</td>
<td>
<?php echo $html->link(
'Delete',
'/posts/delete/'.$post['Post']['id']);?>
</td>
</tr>
<?php endforeach; ?>
<?php
if (sizeof($posts) == 0) {
?>
<tr style= "background-color:#cccccc;">
<td colspan="6">
<span style="font-size: 17px;">
No post found.
</span>
</td>
</tr>
<?php
}
?>
</table>
<br/>
<?php
}
?>
</div>

Related

For loop is going again and again for the same values

I am not sure what is going wrong. But the system is printing the same values again and again, where it should echo the value only once where it is matching student_id in the delivery table. The full code I have edited as requested. This is not executing the query but able display the Table headings.
The code is :
<?php $min = $this->db->get_where('academic_settings' , array('type' =>'minium_mark'))->row()->description;?>
<?php $running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description; ?>
<div class="content-w">
<div class="conty">
<?php include 'fancy.php';?>
<div class="header-spacer"></div>
<div class="content-i">
<div class="content-box">
<div class="row">
<div class="table-responsive">
<table width="100%" class="table table-striped table-lightfont">
<tbody>
<tr>
<td style="color:black !important; text-transform:uppercase; text-align:center;">
<?php echo get_phrase('Subject_Name');?> :
<span><?php echo $row['name'];?></span>
</td>
</tr>
<tr>
<td>
<table class="table table-padded">
<thead style="background-color:#90be2e; color:white;">
<tr style="padding-bottom:4px; padding-top:4px;">
<th style="color:white;"><?php echo get_phrase('Publish Date');?></th>
<th style="color:white;"><?php echo get_phrase('Assignment');?></th>
<th style="color:white;"><?php echo get_phrase('Faculty');?></th>
<th style="color:white;"><?php echo get_phrase('Last Date');?></th>
<th style="color:white;"><?php echo get_phrase('Submitted On');?></th>
<th style="color:white;"><?php echo get_phrase('Marks');?></th>
<th style="color:white;"><?php echo get_phrase('Feedback');?></th>
</tr>
</thead>
<tbody>
<?php
$uploader_id_student = $this->db->get_where('student', array('student_id' => $this->session->userdata('login_user_id')))->row()->student_id;
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach($invoices as $row2):
?>
<tr>
<td>
<?php echo $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row()->upload_date;?>
</td>
<td>
<?php
$get_homework_data = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row();
echo wordwrap($get_homework_data->title,15,"<br>\n");
?>
</td>
<td>
<?php
echo $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row()->first_name;
?>
<?php
echo $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row()->last_name;
?>
</td>
<td>
<?php
$sampleDate1 = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row()->date_end;
$convertDate1 = date("d-m-Y", strtotime($sampleDate1));
echo $convertDate1;
?>
</td>
<td>
<?php
$sampleDate = $row2['date'];
$convertDate = date("d-m-Y", strtotime($sampleDate));
echo $convertDate;
?>
</td>
<td style="text-align:center;">
<?php echo $row2['mark'];?>
</td>
<td>
<?php echo wordwrap($row2['teacher_comment'],25,"<br>\n");?>
</td>
</tr>
<?php endforeach;?>
<!--<?php endforeach;?> -->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
attached is screenshot of table Deliveries is there Deliveries Picture Download
Here is your code updated to fix the performance issues mentioned by Arnold Daniels.
<?php
$uploader_id_student = $this->session->userdata('login_user_id');
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach($invoices as $row2) {
$get_homework_data = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row();
$teacher = $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row();
?>
<tr>
<td>
<?= $get_homework_data->upload_date ?>
</td>
<td>
<?= wordwrap($get_homework_data->title,25,"<br>\n") ?>
</td>
<td>
<?= $teacher->first_name . ' ' . $teacher->last_name ?>
</td>
</tr>
<?php
}
?>
It appears to be working fine as far as I could test it. Is there anything missing from the snippet you posted that could help reproduce your issue?
Edit:
So the complete code would be:
<?php
$min = $this->db->get_where('academic_settings' , array('type' =>'minium_mark'))->row()->description;
$running_year = $this->db->get_where('settings', array('type' => 'running_year'))->row()->description;
?>
<div class="content-w">
<div class="conty">
<?php include 'fancy.php'; ?>
<div class="header-spacer"></div>
<div class="content-i">
<div class="content-box">
<div class="row">
<div class="table-responsive">
<table width="100%" class="table table-striped table-lightfont">
<tbody>
<tr>
<td style="color:black !important; text-transform:uppercase; text-align:center;">
<?php echo get_phrase('Subject_Name'); ?> :
<span><?php echo $row['name']; ?></span>
</td>
</tr>
<tr>
<td>
<table class="table table-padded">
<thead style="background-color:#90be2e; color:white;">
<tr style="padding-bottom:4px; padding-top:4px;">
<th style="color:white;"><?php echo get_phrase('Publish Date'); ?></th>
<th style="color:white;"><?php echo get_phrase('Assignment'); ?></th>
<th style="color:white;"><?php echo get_phrase('Faculty'); ?></th>
<th style="color:white;"><?php echo get_phrase('Last Date'); ?></th>
<th style="color:white;"><?php echo get_phrase('Submitted On'); ?></th>
<th style="color:white;"><?php echo get_phrase('Marks'); ?></th>
<th style="color:white;"><?php echo get_phrase('Feedback'); ?></th>
</tr>
</thead>
<tbody>
<?php
$uploader_id_student = $this->db->get_where('student', array('student_id' => $this->session->userdata('login_user_id')))->row()->student_id;
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach ($invoices as $row2) :
$homework_data = $this->db->get_where('homework', array('homework_code' => $row2['homework_code']))->row();
$teacher = $this->db->get_where('teacher', array('teacher_id' => $get_homework_data->uploader_id))->row();
?>
<tr>
<td>
<?php echo $homework_data->title->upload_date; ?>
</td>
<td>
<?php
echo wordwrap($homework_data->title, 15, "<br>\n");
?>
</td>
<td>
<?php
echo $teacher->first_name;
?>
<?php
echo $teacher->last_name;
?>
</td>
<td>
<?php
$sampleDate1 = $homework_data->date_end;
$convertDate1 = date("d-m-Y", strtotime($sampleDate1));
echo $convertDate1;
?>
</td>
<td>
<?php
$sampleDate = $row2['date'];
$convertDate = date("d-m-Y", strtotime($sampleDate));
echo $convertDate;
?>
</td>
<td style="text-align:center;">
<?php echo $row2['mark']; ?>
</td>
<td>
<?php echo wordwrap($row2['teacher_comment'], 25, "<br>\n"); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
I would need to see the contents of the included file "fancy.php" to be sure. There was an extra endforeach statement, but I'm guessing that it came from somewhere beyond the scope of the snippet you updated. I would need to see the whole content of the file and the content of the included script in order to determine the true nature of the error.
<!--<?php endforeach;?> -->
Remove this Line

Table is not returning values

I want to print out my database into a table, but it isn't working properly.
Here's my code:
<?php
$title = 'Adminpaneel | Gemeente Loket Den Haag';
require 'header.php';
require 'connect.php';
$query = "SELECT * FROM aanvraag";
$result = mysqli_query($db, $query);
?>
<table border="2" >
<thead>
<tr>
<th>Voornaam</th>
<th>Achternaam</th>
<th>email</th>
<th>datum</th>
<th>adres</th>
<td>huisnummer</td>
<td>Postcode</td>
<td>Woonplaats</td>
<td>Product</td>
</tr>
</thead>
<tbody>
<?php
while( $row = mysqli_fetch_assoc($result) ){ ?>
<tr>
<td> <php echo $row['voornaam']; ?> </td>
<td> <php echo $row['achternaam']; ?> </td>
<td> <php echo $row['email']; ?> </td>
<td> <php echo $row['datum']; ?> </td>
<td> <php echo $row['adres']; ?> </td>
<td> <php echo $row['huisnr']; ?> </td>
<td> <php echo $row['postcode']; ?> </td>
<td> <php echo $row['woonplaats']; ?> </td>
<td> <php echo $row['product']; ?> </td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
require 'footer.aanvragen.php';
?>
The rows are created but the database values are missing. What seems to be the issue?
This is the table structure:
Try with this code for the html table:
<?php
while( $row = mysqli_fetch_assoc($result) ){ ?>
<tr>
<td> <?php echo $row['voornaam']; ?> </td>
<td> <?php echo $row['achternaam']; ?> </td>
<td> <?php echo $row['email']; ?> </td>
<td> <?php echo $row['datum']; ?> </td>
<td> <?php echo $row['adres']; ?> </td>
<td> <?php echo $row['huisnr']; ?> </td>
<td> <?php echo $row['postcode']; ?> </td>
<td> <?php echo $row['woonplaats']; ?> </td>
<td> <?php echo $row['product']; ?> </td>
</tr>
<?php } ?>
as suggested by Abhik Chakraborty
<td> <php echo $row['voornaam']; ?> </td>
One line of the output (but it is the same for all the lines):
PHP needs to start with
So the solution will be:
<td><?php echo $row['voornaam']; ?> </td>
But for all the rows...

Parse error: syntax error, unexpected 'else' (T_ELSE) in php

Hey guys I m having a tricky issue but unable to get out of it.
Here I m providing a radio button with namely two option free or paid registration but when I going in else part I m receiving an error.
I checked out the syntax line by line still it is unable to resolve why I m getting and error for else.
Please check and help me out.
<?php $regtype = (isset($postdata['regtype']))? $postdata['regtype']:0;?>
Registration Type: <?php echo $form->radio("regtype",array('0' => $translate->_("Free"),'1' =>$translate->_("Paid")),array('separator'=>"\n",'value'=>$regtype));?>
<?php $type = $_POST['data[regtype]'];?>
<?php if ($type == "Free")
?>
<form action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="POST">
<?php if($agency['monthly_fee'] != ''):?>
<?php echo $form->hidden("monthly_fee",array('value'=>$agency['monthly_fee']));?>
<?php endif;?>
<table class="list" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="200">Plan</th>
<td>
<?php $a="Monthly Rs.600"; $b="3 months Rs. 1,650"; $c="12 months Rs. 6,000"; ?>
<?php echo $form->select("plan",array($a=>'Monthly Rs.600',$b=>'3 months Rs. 1,650',$c=>'12 months Rs. 6,000'),$postdata["plan"]);?>
</td>
</tr>
<tr>
<th width="200"><?php echo $translate->_("student_master_name");?></th>
<td>
<?php echo $translate->_("student_master_name1");?>:<?php echo $form->text("name1",array('value'=>$postdata["name1"]));?>
<?php echo $translate->_("student_master_name2");?>:<?php echo $form->text("name2",array('value'=>$postdata["name2"]));?>
</td>
</tr>
<?php if($gl_locale=="ja"):?>
<tr>
<th>ローマ字</th>
<td>
Surnames:<?php echo $form->text("roma1",array('value'=>$postdata["roma1"]));?>
Given names:<?php echo $form->text("roma2",array('value'=>$postdata["roma2"]));?>
</td>
</tr>
<?php endif;?>
<tr>
<th scope="row"><?php echo $translate->_("student_master_gender");?></th>
<td>
<?php $gender = (isset($postdata['gender']))? $postdata['gender']:0;?>
<?php echo $form->radio("gender",array('0' => $translate->_("common_male"),'1' =>$translate->_("common_female")),array('separator'=>"\n",'value'=>$gender));?>
</td>
</tr>
<tr>
<th scope="row"><?php echo $translate->_("student_master_birth");?></th>
<td>
<?php echo $form->year("birth",1900,date("Y"),$postdata['birth_year'],array('name'=>'data[birth_year]'),"----"); ?><?php echo $translate->_("common_year");?>
<?php echo $form->month("birth",$postdata['birth_month'],array('name'=>'data[birth_month]'),"--");?><?php echo $translate->_("common_month");?>
<?php echo $form->day("birth",$postdata['birth_day'],array('name'=>'data[birth_day]'),"--");?><?php echo $translate->_("common_day");?>
</td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_country");?></th>
<td>
<?php echo $form->select("country_id",$country_data,$postdata['country_id'],array('id'=>'country'),$translate->_("common_choose"));?>
</td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_email");?></th>
<td><?php echo $form->text("email",array('id'=>'mail','value'=>$postdata['email'])); ?></td>
</tr>
<tr>
<th width="200"><?php echo $translate->_("student_master_login_id");?></th>
<td><?php echo $form->text("login_id",array('class'=>'required ||','value'=>$postdata['login_id']));?> <?php echo $translate->_("bmat-entry-tdtxt");?></td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_login_password");?></th>
<td><?php echo $form->password("login_password",array('class'=>'required ||','value'=>$postdata['login_password']));?></td>
</tr>
<tr>
<th><?php echo $translate->_("student_master_login_password");?>(<?php echo $translate->_("bmat-entry-thtxt");?>)</th>
<td><?php echo $form->password("login_password_cfm",array('class'=>'required ||','value'=>$postdata['login_password_cfm']));?></td>
</tr>
</table>
<?php if(!isset($postdata['c-code'])) $postdata['c-code'] = $coupon_code;?>
<?php echo $form->hidden("c-code",array('class'=>'||','value'=>$postdata['c-code']));?>
<?php echo $form->hidden('MemberInfoToken',array('value'=>$MemberInfoToken))?>
<?php echo $form->hidden('stat',array('value'=>'confirm'))?>
<?php //echo $form->hidden('entry_date',array('value'=>date('Y/m/d')))?>
<?php if($gl_locale == 'ja'):?>
<h3><?php echo $translate->_("bmat-entry-kiyaku");?></h3>
<div id="agreement" class="mrg-t10">
<p class="mrg-t10" style="font-weight:bold;">第1条(本規約の適用)</p>
<p>1. 本規約はイープランニング(以下当社という)が運営する特定ドメイン上のウェブサイト 「B-MAT」(以下当社ウェブサイトという)において提供する教育プログラムサービス(以下本サービスという)を、利用者 (第2条にて定義します)が利用する場合の遵守すべき諸条件を定めるものです。</p>
<p>2. 当社は、本サービスの各々について適宜、個別の利用規約(以下「個別規 約」といいます)を定めることができるものとします。</p>
<p style="font-weight:bold;">第2条(ご利用条件について)</p>
<p>利用者には、当社が当該利用者の利用登録を承認した時点で、当社が提供する本サー ビスを利用する資格(以下、「利用者資格」といいます)が与えられます。<br />
利用者は、本利用規約の他、当社が定める各種の規約(以下、「個別規程」といいます)に同意頂き、本サービ スをご利用ください。 なお、本利用規約と個別規程の定めが異なる場合には、個別規程の定めが優先するものとします。<br />
本利用規約および個別規程(以下、併せて「本利用規約等」といいます)については、利用者に対する事前の通 知なく、当社が変更できるものとします。 本利用規約等が変更された場合、当該変更後の利用者による本サービスの利用に は変更後の本利用規約等が適用されるものとし、当該利用により、利用者は当該変更に同意したものとみなされます。</p>
<p style="font-weight:bold;">第3条(著作権について)</p>
<p>本Webサイトに掲載されている著作物(文書、資料、画像、音声、動画等)の著作権は、 イープランニングまたはその他の権利者に帰属します。 これらの著作物につきましては、別段の定めがある場合を除き、私的 使用その他著作権法で特に認められている範囲を超えてご利用(複製、改変、上映、公衆送信、頒布、再使用許諾等を含 む)はできません。 仮に、営利目的でご使用になった場合、相応の使用料をいただくか、使用差し止めの処置を取る場合もあ りますのでご注意ください。</p>
<p style="font-weight:bold;">第4条(利用上の注意)</p>
<p>利用者は、利用に際して登録した情報(以下、「登録情報」といいます。メールアドレス やパスワード等を含みます)について、自己の責任の下、任意に登録、管理するものとします。 利用者は、第三者にパスワ ードを使用されることのないよう、以下の事項を守らなければなりません。</p>
<p>・第三者に自己のパスワードを公開しないこと。<br />
・複数の人間が使用するコンピュータならびに携帯電話上で本サービスを利用する場合は、本 サービスの利用を終えるときに必ずログアウトしウェブブラウザを終了させること。<br />
・複数の人間が使用するコンピュータ上で本サービスを利用する場合は、ログイン情報記録(ログイン時のメールアド レスとパスワードの入力を省略できる機能)の登録解除を行っておくこと。<br />
・当社は、登録されたパスワードによって本サービスの利用があった場合、利用登録をおこな った本人が利用したものと扱うことができ、当該利用によって生じた結果ならびにそれに伴う一切の責任については、利用登録 を行った本人に帰属するものとします。<br />
登録情報の管理は、利用者が自己の責任の下で行うものとし、登録情報が不正確または虚偽であったために利用 者が被った一切の不利益および損害に関して、当社は責任を負わないものとします。</p>
<p style="font-weight:bold;">第5条(個人情報について)</p>
<p>個人情報は、当社が別途定めるプライバシーポリシーに則り、適正に取り扱うこととしま す。 <br />
利用者の同意なく、機密保持契約を結んだ協力企業以外に利用者の個人情報を開示することはありません。ただ し、以下の場合に、個人情報を開示することがあります。</p>
<p>・法令に基づいて、開示が必要であると当社が合理的に判断した場合<br />
・人の生命、身体または財産の保護のために必要がある場合であって、本人の同意を得るこ とが困難であると判断した場合<br />
・公衆衛生の向上または児童の健全な育成の推進のために特に必要がある場合であって、本 人の同意を得ることが困難であると判断した場合<br />
・国の機関もしくは地方公共団体またはその委託を受けた者が法令の定める事務を遂行するこ とに対して協力する必要がある場合であって、本人の同意を得ることにより当該事務の遂行に支障を及ぼすおそれがあると判断 した場合<br />
・合併その他の事由によりサービスの主体が変更され、サービスの継続のため個人情報を移管する必要があると判断した場合</p>
<p>ワールドカップおよびワールドカップJrに入賞した場合は、名前と国名のみ当サイトのワールドカップサイト内に表示します。</p>
<p style="font-weight:bold;">第6条(免責)</p>
<p>・何らかの原因によるシステム障害が起こった場合、その時の獲得ポイントや賞品が無効となる場合があります。<br />
・ポイント獲得および商品交換など、諸所のルールが途中で変更になる場合があります。 </p>
</div><!--agreement-->
<div id="agree-chk">
<input type="hidden" name="data[agree]" value="0">
<label><input name="data[agree]" type="checkbox" value="1"> <?php echo $translate->_("bmat-entry-doui");?></label>
</div>
<?php else:?>
<input type="hidden" name="data[agree]" value="1">
<?php endif;?>
<div style="text-align:center" class="mrg-t10">
<input type="button" name="back" value=" <?php echo $translate->_("otn_member_entry_index_back");?> " onclick="history.back();"/>
<input type="submit" name="btnSubmit" value=" <?php echo $translate->_("otn_member_entry_index_confirm");?> " />
</div>
<?php endif;?>
</form>
<?php else:?> **<!-- Here I m getting an error -->**
<label>In paid registration</label>
<?php endif;?>
Looks like you might have an extra end if:
<?php else:?>
<input type="hidden" name="data[agree]" value="1">
<?php endif;?>
<div style="text-align:center" class="mrg-t10">
<input type="button" name="back" value=" <?php echo $translate->_("otn_member_entry_index_back");?> " onclick="history.back();"/>
<input type="submit" name="btnSubmit" value=" <?php echo $translate->_("otn_member_entry_index_confirm");?> " />
</div>
<?php endif;?>

getting error in zend framework

print data after inner join of two tables in table format
I am getting following error in below code:
Parse error: syntax error, unexpected end of file in
/home/bina/public_html/studentzend/application/views/scripts/index/index.phtml
on line 57
Here is my code:
<?php if (count($this->messages)) : ?>
<ul id="messages">
<?php foreach ($this->messages as $message) : ?>
<li><?php echo $this->escape($message); ?></li>
<?php endforeach; ?> </ul>
<?php endif; ?>
<div class="row">
<div class="span12">
<a class="btn btn-primary" role="button" href="<?php echo $this->url(array('controller' => 'Index', 'action' => 'create')); ?>">Create Student</a>
<h3>Recent Students</h3>
<table class="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>FirstName</th>
<th>LastName</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<body>
<?php
if(empty($this->students))
{
echo "<tr>";
echo "<td><center>NO records found</center></td>";
echo "</tr>";
}
else
{
//print_r($this->students);exit;
$students=$this->students;
$length= sizeof($this->students);
//echo $length;exit;
for($i=0;$i<$length;$i++){ ?>
<tr>
<td><?php echo $students[$i]['id']; ?> </td>
<td><?php echo $students[$i]['firstname']; ?> </td>
<td><?php echo $students[$i]['lastname']; ?> </td>
<td><?php echo $students[$i]['email']; ?></td>
<td>
Edit |
Delete</td>
</tr>
<?php } ?>
</body>
</table>
</div>
You are just missing a closing brace } for your else statement.
Delete</td>
</tr>
<?php }} ?>
//^-------- Add one there

advice on refreshing incoming messages with mt_rand()?

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.

Categories