View can't call Controller Function Zend Framework 2 - php

I can't call my controller in view page. even if i use print_r in controller but it didn't show. I have body_product.phtml view code:
<table class="table table-hover table-condensed">
<tbody>
<?php
$i = 1;
//print_r("list produk:".$this->productList);
foreach ($this->productList as $data) {
$desc=explode(",",$data['descriptions']);
?>
<tr>
<th colspan="3">
<input type="hidden" id="id_pack" name="id_pack" value="<?php echo $data['package_id']; ?>">
<input type="hidden" id="nama_pack" name="nama_pack" value="<?php echo $data['package_name']; ?>">
<h4 align="center" class="title-pack"><?php echo $data['package_name']; ?></h4>
</th>
</tr>
<tr id="dashe">
<td>
<ul class="myul">
<?php foreach($desc as $descriptions) { ?>
<li class="myli"> <?php echo $descriptions; ?></li>
<?php } ?>
</ul>
</td>
<td>
<h4 class="prize">
<?php setlocale(LC_MONETARY, 'id_ID');
echo money_format('%.2n', $data['package_price']); ?>
/ month
</h4>
</td>
<td>
<p id="btn-hrm" class="mybutton" data-toggle="modal" data-target=".mymodal">Order</p>
</td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
and in the indexController:
public function loadProductAction() {
$viewModel = new ViewModel();
$storage = Product\Storage::factory($this->getDb());
$productList = new Product($storage);
$data = $productList->loadProduct();
$arr = array();
if ($data) {
foreach ($data as $val) {
array_push($arr, $val);
}
}
print_r('teaaat'.$arr);
$viewModel->setVariables(array('productList' => $arr))
->setTerminal(true);
return $viewModel;
}
If I open print_r in the view,it show error Warning: Invalid argument supplied for foreach() in.... I think it cause of view can't call the controller.
Help me please,thanks.

Firstly when you try to use print_r it is expecting an array. So it should be something like print_r($arr). Also give this a try and see if it helps.
public function loadProductAction() {
$storage = Product\Storage::factory($this->getDb());
$productList = new Product($storage);
$data = $productList->loadProduct();
$arr = array();
if (is_array($data) && !empty($data)) {
foreach ($data as $val) {
array_push($arr, $val);
}
} else {
echo '$data is not an array or it is empty';
}
print_r($arr);
return new ViewModel(array(
'productList' => $arr
));
}

Related

Codeigniter anchor tag hyperlinked to a form in controller but the data shown outside the table

I am using Codeigniter 3 and trying CRUD operation. I have created the basic crud operation and am showing the data in a table however I have linked a paragraph tag in the controller below the table to the form controller, If I want to enter another data
The issue is when I click on the link to enter another data it redirect me the original form in controller but when I enter the data and submit it, The data is shown below the table in the paragraph tag.
I am not able understand why this is happening as the controller is the same
I had faced a similar issue before when redirecting in controller.I had redirected the page after submission to show_form() controller which was basically redirecting the page to $this->load->view('learn/view_form');
in which I have kept a condition that if No data is present click to enter. Now when it redirects to show_form() controller it goes into else condition even if the data is present
CONTROLLER
<?php
defined('BASEPATH') OR exit("No direct script access allowed");
class Learning extends CI_Controller{
public function __construct(){
parent::__construct();
$this ->load->helper("url");
$this->load->model("tatti_test");
$this->load->database();
$this->load->helper();
}
//functions should be passed here
//creating a function
function start_learn() {
//this varible
$this->load->view('learn/start_learn');
}
function start_crud(){
$this->load->view('learn/form');
}
function show_form(){
$this->load->view("learn/view_form");
}
function insert_form(){
$name = $this->input->post("u_name");
$email = $this->input->post("u_email");
$mobile = $this->input->post("u_mobile");
//File Uploading
$config['upload_path']="./assets/images/";
$config["allowed_types"]="gif|jpg|png";
$config['encrypt_name']=true;
$this->load->library("upload",$config);
if(!$this->upload->do_upload("u_file")){
$file='noimage.png';
}
else {
$filework = $this->upload->data();
$file =$filework['file_name'];
}
$data = array(
"name"=>$name,"email"=>$email,"mobile"=>$mobile,"file_name"=>$file
);
$this->tatti_test->insert_tatti($data);
redirect("learning/view_form");
}
function view_form(){
$data['returned_data']=$this->tatti_test->show_form();
$this->load->view("learn/view_form",$data);
}
function delete_entry(){
$id=$this->uri->segment(3);
$data=$this->tatti_test->for_unlink($id);
$filepath="./assets/images/".$data['file_name'];
unlink($filepath);
$this->tatti_test->delete_entry($id);
redirect('learning/view_form');
}
function time_to_update(){
$id=$this->uri->segment(3);
$data['fetched_update_entry']=$this->tatti_test->update_entry($id);
$this->load->view("learn/update.php",$data); //bus associative array hi leta hai
}
function up_db(){
$name =$this->input->post('up_name');
$email = $this->input->post('up_email');
$mobile = $this->input->post('up_mobile');
$file = $this->input->post('up_file');
$id = $this->input->post('up_id');
//File Uploading
$config['upload_path']="./assets/images/";
$config["allowed_types"]="gif|jpg|png";
$config['encrypt_name']=true;
$this->load->library("upload",$config);
if(!$this->upload->do_upload("up_file")){
$data= $this->tatti_test->remove_prev($id);
$file=$data['file_name'];
}
else {
$data= $this->tatti_test->remove_prev($id);
$path="./assets/images/".$data['file_name'];
unlink($path);
$filework = $this->upload->data();
$file =$filework['file_name'];
}
$data = array(
"name"=>$name,"email"=>$email,"mobile"=>$mobile,"file_name"=>$file
);
$this->tatti_test->up_nw($data,$id);
redirect('learning/view_form');
}
} /*this accesses command from main ci controller */
?>
VIEW
<?php $this->load->view("common/header.php");
if ($returned_data != 0){ ?>
<table border='1'>
<tr>
<th>Sr No</th>
<th>Name</th>
<th>Password</th>
<th>Mobile</th>
<th>Email</th>
<th>Final Name</th>
<th>Delete</th>
<th>View</th>
</tr>
<?php $i=0; foreach ($returned_data as $key=>$d){
?>
<tr>
<td>
<?php echo ++$i; ?>
</td>
<td>
<?php echo $d['name'];?>
</td>
<td>
<?php echo $d['mobile'];?>
</td>
<td>
<?php echo $d['email'];?>
</td>
<td>
<?php echo $d['file_name'];?>
</td>
<td>
<img src="<?php echo base_url().'/assets/images/'.$d['file_name'];?>" width="100px" ; height="100px" />
</td>
<td>Edit</td>
<td>Delete</td>
</tr>
</table>
<p>Add another entry
<?php echo anchor("learning/start_crud"," here "); ?>
</p>
<?php } ?>
<?php } else { ?>
<p>No data to show please click
<?php echo anchor("learning/start_crud"," here "); ?>to enter</p>
<?php } ?>
<?php $this->load->view("common/footer.php");
MODEL
<?php
class Tatti_test extends CI_Model{
function insert_tatti($insert_data){
$this->db->insert("f_form",$insert_data);
}
function show_form(){
$query = $this->db->get("f_form");
$response=[];
if ($query->num_rows() > 0){
$response = $query->result_array();
}
else {
$response = 0;
}
return $response;
}
function for_unlink($id){
$this->db->where("id",$id);
$query = $this->db->get("f_form");
$response=[];
foreach ($query->result_array() as $rows){
return $response = $rows;
}
}
function delete_entry($id){
$this->db->where("id",$id);
$this->db->delete("f_form");
}
function update_entry($id){
$this->db->where("id",$id);
$query = $this->db->get("f_form");
$response = [];
if($query->num_rows() > 0 ){
foreach($query->result_array() as $rows);
$response = $rows;
}
return $response;
}
function up_nw($introduced_data,$id){
$this->db->set($introduced_data);
$this->db->where('id',$id);
$this->db->update('f_form');
}
function remove_prev($id){
$this->db->where('id',$id);
$query = $this->db->get('f_form');
$response = [];
foreach($query->result_array() as $rows){
$response=$rows;
}
return $response;
}
}
?>
This is how the data is showing when clicked on the link below table
enter image description here
You're html formatting is messed up. You should have the closing </table> outside your foreach loop or premature <table> closure.
Also moved the Add another entry link outside the foreach loop. So it only appears once, and your document format not messed up.
You can use this fixed view instead:
<?php $this->load->view("common/header.php");
if ($returned_data != 0){ ?>
<table border='1'>
<tr>
<th>Sr No</th>
<th>Name</th>
<th>Password</th>
<th>Mobile</th>
<th>Email</th>
<th>Final Name</th>
<th>Delete</th>
<th>View</th>
</tr>
<?php $i=0; foreach ($returned_data as $key=>$d){
?>
<tr>
<td>
<?php echo ++$i; ?>
</td>
<td>
<?php echo $d['name'];?>
</td>
<td>
<?php echo $d['mobile'];?>
</td>
<td>
<?php echo $d['email'];?>
</td>
<td>
<?php echo $d['file_name'];?>
</td>
<td>
<img src="<?php echo base_url().'/assets/images/'.$d['file_name'];?>" width="100px" ; height="100px" />
</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<?php } ?>
</table>
<p>Add another entry
<?php echo anchor("learning/start_crud"," here "); ?>
</p>
<?php } else { ?>
<p>No data to show please click
<?php echo anchor("learning/start_crud"," here "); ?>to enter</p>
<?php } ?>
<?php $this->load->view("common/footer.php");
I realize that you are trying to do CURD,
first of all, try this to improve your code and fill the missing library of codeigniter: https://github.com/avenirer/CodeIgniter-MY_Model
For your code:
No data passed to the view in show_form(),
You should check the form submission and the conditions to load the view,
simple thing to do is follow the best practice using ready scripts,
Hope this will be useful,

Codeigniter multiple foreach loop

I have two tables meals type and meals. I want to print each meals corresponding to its meals type.
Error is that only showing last meals type meals only
view page is like
View
<?php
foreach ($mealstype as $type) {
?>
<h2><?php echo $type->type; ?></h2>
<table class="table table-bordered">
<tr>
<th>Meals</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<?php
foreach ($meals as $meals_get) {
?>
<tr>
<td><?php echo $meals_get->item; ?></td>
<td><?php echo $meals_get->price; ?></td>
</tr>
<?php } ?>
<tr>
<td> <input type="checkbox" class="ck" value="total"> Toal</td>
<td>2050</td>
</tr>
</tbody>
</table>
<?php
}
?>
Controller
function availability() {
$this->data['mealstype'] = $this->Home_model->mealstype();
foreach ($this->data['mealstype'] as $type) {
$typeid = $type->id;
$meals[] = $this->Home_model->meals($typeid, $hotel_id);
}
$this->data['meals'] = $meals[];
$this->load->view('home2', $this->data);
}
Please check this answer
Controller:
public function availability() {
$build_array = array();
mealstype= $this->Home_model->mealstype();
foreach($mealstype as $row){
$build_array[] = array(
'parent_array' => $row,
'child_array' =>$this->Home_model->meals($row->id,$hotel_id),
'child_sum' =>$this->Home_model->meals_sum($row->id,$hotel_id)
);
}
$this->data['build_array'] = $build_array;
}
and the view page is like this:
View:
<?php foreach($build_array as $type){?>
<h2><?php echo $type['parent_array']->type;?></h2>
<table class="table table-bordered">
<tr>
<th>Meals</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<?php
foreach ($type["child_array"] as $meals_get) {?>
<tr>
<td><?php echo $meals_get->item;?></td>
<td><?php echo $meals_get->price;?></td>
</tr>
<?php }?>
<tr>
<td> Toal</td>
<td>2050</td>
</tr>
<?php } ?>
Controller, check "hotel_id"
function availability()
{
$this->data['mealstype'] = $this->Home_model->mealstype();
if( count( $this->data['mealstype'] ) > 0 )
{
foreach($this->data['mealstype'] as $type)
{
$type->meals = $this->Home_model->meals( $type->id, $hotel_id ); // hotel_id no declared???
}
}
$this->load->view('home2', $this->data);
}
View
<?php if( count( $mealstype ) > 0): foreach( $mealstype as $type ): ?>
<h2><?php echo $type->type; ?></h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Meals</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<?php if( count( $type->meals ) > 0 ): foreach( $type->meals as $meals_get ): ?>
<tr>
<td><?php echo $meals_get->item; ?></td>
<td><?php echo $meals_get->price; ?></td>
</tr>
<?php endforeach; endif; ?>
<tr>
<td><input type="checkbox" class="ck" value="total"> Toal</td>
<td>2050</td>
</tr>
</tbody>
</table>
<?php endforeach; endif ?>
Try to replace into this :
function availability() {
$data = array();
$data['mealstype'] = $this->Home_model->mealstype();
foreach ($data['mealstype'] as $type) {
$typeid = $type->id;
$type->meals = $this->Home_model->meals($typeid,$hotel_id);
}
$this->load->view('home2', $data);
}
check it and print_r($data); what it comes set on the basis of that in view file..
You have $hotel_id I am not sure where you set this I can not see it any where else.
We also need to see your model
public function availability() {
$data['mealstypes'] = array();
$mealstypes = $this->home_model->mealstype();
foreach ($mealstypes as $mealstype)
{
$meals = array();
$meals_results = $this->home_model->meals($mealstype->id, $hotel_id);
foreach ($meals_results $meal_result) {
$meals[] = array(
'mealstype' => $meal_result->mealstype,
'price' => $meal_result->price
);
}
$data['mealstypes'][] = array(
'type' => $mealstype->type
'meals' => $meals
);
}
$this->load->view('someview', $data);
}
View
<?php foreach ($mealstypes as $mealstype) {?>
<h2><?php echo $mealstype['type'];?></h2>
<?php foreach ($mealstype['meals'] as $meal) {?>
<?php echo $meal['mealstype'];?>
<?php echo $meal['price'];?>
<?php }?>
<?php }?>

Delete multiple image from database also database using codeigniter

I just created code that deletes an image from database and also from folder which is an image store, but only one image is successfully deleted from thedatabase and folder when I click "check all". What did I do wrong? Here is my view using check box javascript:
<form name="indonesia" action="<?php echo site_url('admin/wallpaper/delete'); ?>" method="post">
<button type="submit" class="btn btn-danger" name="hapus" value="hapus">Hapus</button>
<?php echo anchor('admin/wallpaper/tambah', 'Tambah Wallpaper');?>
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>
<button type="button" class="btn btn-info" onClick="check_all()" >Check</button>
<button type="button" class="btn btn-success" onClick="uncheck_all()" >Un-Check</button>
</th>
<th>id</th>
<th>Keterangan</th>
<th>Gambar</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($ListWallpaper->result() as $row)
{
?>
<tr>
<td><input type="checkbox" name="item[]" id="item[]" value="<?=$row->id_wall ?>"></td>
<td><?=$row->id_wall ?></td>
<td><?=$row->ket ?></td>
<td><?=$row->wall ?></td>
<td>
Delete
Update
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
and here is my controller
public function delete()
{
$ownerNames = $this->input->post('item');
foreach ($ownerNames as $ownerName => $k) {
//echo "Array : " . $k . "<br/>";
$photo = $this->wallpaper_model->del_photo($k);
if ($photo->num_rows() > 0)
{
$row = $photo->row();
$file_photo = $row->wall;
echo "$file_name</br>";
$path_file = 'image/wallpaper/';
unlink($path_file.$file_photo);
}
$this->wallpaper_model->drop_photo($k);
redirect('admin/wallpaper','refresh');
}
}
and my model
function del_photo($k)
{
$this->db->where('id_wall',$k);
$query = $getData = $this->db->get('tabel_wall');
if($getData->num_rows() > 0)
return $query;
else
return null;
}
function drop_photo($k)
{
$this->db->where('id_wall',$k);
$this->db->delete('tabel_wall');
}
Only one image is successfully deleted from the folder and database too, but when I try to echo "$file_name</br>"; it show all images. What did I do wrong? if anyone can guide me, I will appreciate that.
First off I would set a array of images from controller to view, $data['wallpapers'] = array(); for some of the site_url you may need to include in your route.php $route['controller/update/(:any)'] = "controller/update/$1"
To Delete selected images, You could do a selected post in array() and then on the value check box name=""
Disclaimer: This is just for a example only.
public function index() {
$k = $this->uri->segment(what ever); // Use uri segment is id example.com/image/1 = $this->uri->segment(2);
$results = $this->model_name->del_photo($k);
$data['wallpapers'] = array();
foreach ($results as $result) {
$data['wallpapers'][] = array(
'id_wall' => $result['id_wall'],
'update' => site_url('controllername/update' .'/'. $result['wall_id']),
'ket' => $result['ket']
);
}
$data['delete'] = site_url('controller/function');
$selected = $this->input->post('selected');
if (isset($selected)) {
$data['selected'] = (array)$selected;
} else {
$data['selected'] = array();
}
$this->load->view('your list', $data);
}
public function update() {
//update info here
}
public function delete() {
$selected = $this->input->post('selected');
if (isset($selected)) {
foreach ($selected as $image_id) {
$wall_id = $image_id
$this->db->query("DELETE FROM " . $this->db->dbprfix . "TABLENAME WHERE wall_id = '" . (int)$wall_id . "'");
}
}
}
View
Added echo delete from controller as site url.
<form action="<?php echo $delete;?>" method="post">
<table>
<thead>
<tr>
<td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>
<td>Update</td>
</tr>
</thead>
<tbody>
<?php if ($wallpapers) { ?>
<?php foreach ($wallpapers as $wallpaper) { ?>
<td class="text-center"><?php if (in_array($wallpaper['id_wall'], $selected)) { ?>
<input type="checkbox" name="selected[]" value="<?php echo $wallpaper['id_wall']; ?>" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="selected[]" value="<?php echo $wallpaper['id_wall']; ?>" />
<?php } ?>
</td>
<td>Update</td>
<?php } ?>
<?php } ?>
</tbody>
</table>
</form>
Model
function del_photo($k) {
$this->db->where('id_wall',$k);
$query = $this->db->get('table_name');
if($query->num_rows() > 0) {
$return = $query->result_array();
} else {
return false;
}
}
In controller, move redirect directive outside of foreach loop.

Need help changing table array by moving a column in PHP

I have been handed the task of making some changes to a PHP webpage that was coded by someone who has left the company and my Php is exactly exeprt.
The page in question displays a database table in a SQL server that allows you to update values via an update page.
Currently the Update function sits under the 'Action' column at the end of the table and I need to relocate the 'Action' column to the start of the table before the 'Name' column.
When I try to make changes, I break the table array and the 'Update' function no longer works.
Current order of columns are;
Name,
Value,
Details,
Action
The new order of columns attempting to achieve
Action,
Name,
Value,
Details
I have also included the code in question.
Any assistance would be appreciated
Note** It is a Php website running on a Windows box and connecting to a MSSQL Server 2008
$query = sqlsrv_query($conn, 'SELECT * FROM Database_Values ORDER BY Name ASC');
// Did the query fail?
if (!$query) {
die( FormatErrors( sqlsrv_errors() ) );
}
// Dump all field names in result
$field_name = "";
foreach (sqlsrv_field_metadata($query) as $fieldMetadata) {
foreach ($fieldMetadata as $name => $value) {
if ($name == "Name") {
$field_name .= $value . '-';
}
}
}
$field_name = substr_replace($field_name, "", -1);
$names = explode("-", $field_name);
?>
<div style="max-height:610px; overflow:auto;">
<table border="1" cellspacing="0" cellpadding="0" bordercolor="#ccc" class="table" width="100%">
<tr>
<?php
foreach ($names as $name) {
?>
<th><?php echo $name; ?></th>
<?php
}
?>
<th>Action</th>
</tr>
<?php
// Fetch the row
while ($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)) {
//print_r($row);
?>
<tr>
<?php
foreach ($row as $key => $eachrow) {
?>
<td nowrap="nowrap">
<?php echo $eachrow; ?>
</td>
<?php
}
?>
<td nowrap="nowrap">
<?php $groupid = $_SESSION["gid"] ;
if($groupid!='1') {
?>
<a href="javascript:void(0);" title="Permission Restricted" >Update</a>
<?php } else { ?>
Update
<?php } ?>
</td>
</tr>
<?php
}
?>
</table>
</div>
All you need to do is change the order of the th and td cells in the html
$query = sqlsrv_query($conn, 'SELECT * FROM Database_Values ORDER BY Name ASC');
// Did the query fail?
if (!$query) {
die( FormatErrors( sqlsrv_errors() ) );
}
// Dump all field names in result
$field_name = "";
foreach (sqlsrv_field_metadata($query) as $fieldMetadata) {
foreach ($fieldMetadata as $name => $value) {
if ($name == "Name") {
$field_name .= $value . '-';
}
}
}
$field_name = substr_replace($field_name, "", -1);
$names = explode("-", $field_name);
?>
<div style="max-height:610px; overflow:auto;">
<table border="1" cellspacing="0" cellpadding="0" bordercolor="#ccc" class="table" width="100%">
<tr>
<th>Action</th>
<?php
foreach ($names as $name) {
?>
<th><?php echo $name; ?></th>
<?php
}
?>
</tr>
<?php
// Fetch the row
while ($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)) {
//print_r($row);
?>
<tr>
<td nowrap="nowrap">
<?php $groupid = $_SESSION["gid"] ;
if($groupid!='1') {
?>
<a href="javascript:void(0);" title="Permission Restricted" >Update</a>
<?php } else { ?>
Update
<?php } ?>
</td>
<?php
foreach ($row as $key => $eachrow) {
?>
<td nowrap="nowrap">
<?php echo $eachrow; ?>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</div>

Using foreach to display results

I'm trying to write some sort of forum homepage, based off work someone else did. Here's what I've got so far:
Forums
<?php
$crumbs = explode(",", $user['data']['depts']);
foreach ($crumbs as &$value) {
$data = $db->query("SELECT * FROM tbl_depts WHERE id = '" . $value . "'");
$crumb = $data->fetch_assoc();
$data = $db->query("SELECT * FROM tbl_forums WHERE deptid = '" . $value . "'");
$forumcount = $data->num_rows;
$forum = $data->fetch_assoc();
?>
<div class="h3top"><?php echo $crumb['name']; ?></div>
<div class="info2alt">
<?php
while (($row = $data->fetch_array()) !== FALSE) {
$forum[] = $row;
}
foreach ($forum as $row) {
if ($forumcount >= 1) {
if ($forum['lastpost'] == "") {
$forum['lastpost'] = "--";
}
?>
<div class="info4">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td width="55%" align="left" valign="middle" class="zebraodd"><?php echo $row['name']; ?></td>
<td width="10%">Threads: <?php echo $forum['threadcount']; ?><br />Posts: <?php echo $forum['postcount']; ?></td>
<td width="35%">Last Post: <?php echo $forum['lastpost']; ?></td>
</tr>
</table>
</div>
<?php
}
?>
<?php if ($forumcount >= 1) { ?>
<div class="info3bottom"></div>
<?php
}
}
?>
</div>
<?php
}
?>
This is the current data in the table:
Now, when I try to use this code, I get this:, such that the first one is shown so many times, however, the next one does not appear.
How do I fix this?
you want to use $value['threadcount'] etc. $forum is the array containing all the rows. i wonder that you get some output at all …
fetch_assoc() will only fetch a single row from the resultset. you'd have to use a loop to fill an array:
while(($row = $data->fetch_assoc()) !== FALSE) {
$forum[] = $row;
}
you can then iterate over your $forum array with a foreach loop:
foreach($forum as $row) {
echo htmlspecialchars($row['threadcount']);
// etc.
}
trying to fix this mess …
<?php
$crumbs = explode(",", $user['data']['depts']);
foreach ($crumbs as $crumb) { ?>
<div class="h3top"><?php echo htmlspecialchars($crumb['name']);?></div>
<?
}
$result = $db->query("SELECT * FROM tbl_forums WHERE deptid = " . (int)$id . "");
$forumcount = $result->num_rows;
while(($row = $data->fetch_assoc()) !== FALSE) {
if ($row['lastpost'] == "") { $row['lastpost'] = "--";}
?>
<div class="info2alt">
<div class="info4">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td width="55%" align="left" valign="middle" class="zebraodd"><?php echo htmlspecialchars($forum['name']); ?></td>
<td width="10%">Threads: <?php echo htmlspecialchars($forum['threadcount']); ?><br />Posts: <?php echo htmlspecialchars($forum['postcount']); ?></td>
<td width="35%">Last Post: <?php echo htmlspecialchars($forum['lastpost']); ?></td>
</tr>
</table>
</div>
<div class="info3bottom"></div>
<?php
}
?>

Categories