Page numbers not displaying - php

Anyone have any idea why my page numbers are not listing inside of the pagination div? I'm using the tablesorter.pager plugin.
<?php
session_start();
require("../inc/dbconfig.php");
require("../inc/global_functions.php");
// find out how many rows are in the table
$query = "SELECT CONCAT_WS(' ',firstName,lastName) AS name, username, emailAddress, userID FROM manager_users WHERE statusID != 4";
$result = mysqli_query($dbc,$query);
$fileName = basename($_SERVER['PHP_SELF']);
$pageName = "User Accounts";
$userData = $_SESSION['user_data'];
$userID = $userData['userID'];
?>
<script type="text/javascript">
$(document).ready(function() {
$('a.bt_green').click(function(e) {
e.preventDefault();
$('div.right_content').load('forms/addnew/' + $(this).attr('id'));
});
$('#usersPageList').tablesorter().tablesorterPager({container:$('#pagination'),cssPageLinks:'a.pageLink', positionFixed: false});
$('table tr').click(function() {
checkBox = $(this).children('td').children('input[type=checkbox]');
if(checkBox.attr('checked'))
checkBox.removeAttr('checked');
else
checkBox.attr('checked', 'checked');
});
$('.ask').jConfirmAction();
$('.ask2').jConfirmAction();
});
</script>
<h2>User Accounts</h2>
<table id="usersPageList" class="rounded-corner">
<thead>
<tr>
<th scope="col" class="rounded-first"></th>
<th scope="col" class="rounded">Name</th>
<th scope="col" class="rounded">Email Address</th>
<th scope="col" class="rounded">Username</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-last">Delete</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5" class="rounded-foot-left"><em>Displays all of the registered and verified users!</em></td>
<td class="rounded-foot-right"> </td>
</tr>
</tfoot>
<tbody>
<?php
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr>";
echo "<td><input type=\"checkbox\" name=\"users[]\" value=\"".$row['userID']."\"/></td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['emailAddress']."</td>";
echo "<td>".$row['username']."</td>";
echo "<td><img src=\"images/user_edit.png\" alt=\"\" title=\"\" border=\"0\" /></td>";
echo "<td>";
if (($row['userID'] !== '10000') && ($row['userID'] !== $userID)){
echo "<img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" />";
}
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<div id="pagination"></div>
<?php
addRemove($fileName,$pageName);
?>
<input type="hidden" name="myhiddenPageToken" id="myhiddenPageToken" value="useraccounts" />
EDIT POST:
<script type="text/javascript">
$(document).ready(function() {
$('a.bt_green').click(function(e) {
e.preventDefault();
$('div.right_content').load('forms/addnew/' + $(this).attr('id'));
});
$('#usersPageList').tablesorter().tablesorterPager({container:$('#pagination'),cssPageLinks:'a.pageLink', positionFixed: false});
$('table tr').click(function() {
checkBox = $(this).children('td').children('input[type=checkbox]');
if(checkBox.attr('checked'))
checkBox.removeAttr('checked');
else
checkBox.attr('checked', 'checked');
});
$('.ask').jConfirmAction();
$('.ask2').jConfirmAction();
});
</script>
<h2>User Accounts</h2>
<table id="usersPageList" class="rounded-corner">
<thead>
<tr>
<th scope="col" class="rounded-first"></th>
<th scope="col" class="rounded">Name</th>
<th scope="col" class="rounded">Email Address</th>
<th scope="col" class="rounded">Username</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-last">Delete</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5" class="rounded-foot-left"><em>Displays all of the registered and verified users!</em></td>
<td class="rounded-foot-right"> </td>
</tr>
</tfoot>
<tbody>
<tr><td><input type="checkbox" name="users[]" value="10000"/></td><td>KOW Management</td><td>kowmanagement#kansasoutlawwrestling.com</td><td>Administrator</td><td><img src="images/user_edit.png" alt="" title="" border="0" /></td><td></td></tr><tr><td><input type="checkbox" name="users[]" value="10001"/></td><td>Jeff Davidson</td><td>xtremer360#yahoo.com</td><td>xtremer360</td><td><img src="images/user_edit.png" alt="" title="" border="0" /></td><td></td></tr>
</tbody>
</table>
<div id="pagination"></div>
<span class="bt_green_lft"></span><strong>Add New User Accounts</strong><span class="bt_green_r"></span><span class="bt_blue_lft"></span><strong>View all User Accounts</strong><span class="bt_blue_r"></span><span class="bt_red_lft"></span><strong>Delete User Accounts</strong><span class="bt_red_r"></span><input type="hidden" name="myhiddenPageToken" id="myhiddenPageToken" value="useraccounts" />

For the tablesorterPager plugin to work in your code I had to add a pagination form myself. I changed the pagination div to this, copied from the documentation:
<div id="pagination">
<form>
<img src="../addons/pager/icons/first.png" class="first"/>
<img src="../addons/pager/icons/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="../addons/pager/icons/next.png" class="next"/>
<img src="../addons/pager/icons/last.png" class="last"/>
<select class="pagesize">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
</form>
</div>
The tablesorterPager now works, and also fixes the tablesorter which breaks if tablesorterPager can't find the form.
I can't see any reference in jquery.tablesorter.pager.js to generate the form itself, so I guess you'll have to create it server-side based on the number of results in the table, and the number of results you'd like per page.
Hope that helps

Related

How to hide table row?

I am trying to hide the table row for user_id. I only want to show the full name, user name, and actions in the table. I tried to remove the code for the user id row, but it affected the other functionalities like the edit and delete.
here is the code:
<form method="post" id="editForm">
<table class="table">
<tbody>
<tr>
<th scope="col">USER ID</th>
<th scope="col">FULL NAME</th>
<th scope="col">USER NAME</th>
<th scope="col">ACTIONS</th>
</tr>
<?php $a = 0?>
<?php while ($row = mysqli_fetch_array($res)) {
echo "<tr id=".$a++.">
<th scope='row' class='row-data'>".$row['user_id']."</th>
<td class='row-data'>".$row['full_name']."</td>
<td class='row-data'>".$row['user_name']."</td>
<td><input type='button'
value='EDIT'
onclick='editUser()'' /></td>
<td><input type='button'
value='DELETE'
onclick='deleteUser()' /></td>
</tr>
</tbody>";
}; ?>
You could try modifying the editUser() and deleteUser() Javascript methods to accept a userId parameter. It would probably clean up some of the code as well on the JS side. Just a suggestion though. That snippet then might look something like this:
<form method="post" id="editForm">
<table class="table">
<tbody>
<tr>
<th scope="col">FULL NAME</th>
<th scope="col">USER NAME</th>
<th scope="col">ACTIONS</th>
</tr>
<?php $a = 0?>
<?php while ($row = mysqli_fetch_array($res)) {
echo "<tr id='".$a++."'>
<td class='row-data'>".$row['full_name']."</td>
<td class='row-data'>".$row['user_name']."</td>
<td><input type='button'
value='EDIT'
onclick='editUser(".$row['user_id'].")'' /></td>
<td><input type='button'
value='DELETE'
onclick='deleteUser(".$row['user_id'].")' /></td>
</tr>
</tbody>";
}; ?>
Otherwise you could use Ken's solution which would probably work with your existing code.
Instead of removing the column, you can set the display style to 'none' for this column
(add style="display:none;")
Hence (1) change
<th scope="col">USER ID</th>
to
<th scope="col" style="display:none;">USER ID</th>
and (2) change
<th scope='row' class='row-data'>".$row['user_id']."</th>
to
<th scope='row' class='row-data' style="display:none;">".$row['user_id']."</th>

Php help to remove remove td line

Hello i just create my support system and i get ticket detalis with echo but it show all td line as picture i need to show only the first line
my code
<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
<th width="115"><p2>Ticket ID</p2></th>
<th width="90"><p2>Status</p2></th>
<th width="160"><p2>Ticket Topic</p2></th>
<th width="160"><p2>Client</p2></th>
</tr>
</thead>
<tr> <?php
echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
echo "<td>".$row[status]."</td>";
echo "<td>".$row[naslov]."</td>";
$userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
$useri = mysql_fetch_array($userr);
echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
?>
</tr>
you need to move your table header outside the loop. without seeing the mechanics of the loop, I'm guessing it will need to look similar to this:
<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
<th width="115"><p2>Ticket ID</p2></th>
<th width="90"><p2>Status</p2></th>
<th width="160"><p2>Ticket Topic</p2></th>
<th width="160"><p2>Client</p2></th>
</tr>
</thead>
<tbody>
<?php include 'missing.query.on.other.script.php';
while ($row = mysql_fetch_array($whatever_resource)){
?>
<tr> <?php
echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
echo "<td>".$row[status]."</td>";
echo "<td>".$row[naslov]."</td>";
$userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
$useri = mysql_fetch_array($userr);
echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
?>
</tr>
<?php } // end while ?>
</tbody>
</table>

jQuery.FilterTable doesn't work on a table created with php

I found this plugin JQuery.FilterTable for searching on a table bun when i put at my table doesn't work .
I don't know what is the problem but from my opinion i think is because the table is made with PHP and the datas for table are from database.
The code lis like this:
<div class="issue-table">
<table class="table table-striped" id="data-table">
<thead>
<tr>
<th scope="col" title="President Number">Nr:</th>
<th scope="col">Brand</th>
<th scope="col">Model</th>
<th scope="col">Color</th>
<th scope="col">Release date</th>
<th scope="col">Price</th>
<?php
if ($user->data()->type == 1) {
echo "<th>Delete</th>";
}
?>
</tr>
</thead>
<tbody>
<?php
$x = 1;
foreach ($car as $index => $car_val) {
$cars = DB::table('brands')->get(['id','=',$car_val->id_make]);
$car_name = $cars->first()->name;
echo "<tr>";
echo "<td>".$x++."</td>";
echo "<td>".$car_name."</td>";
echo "<td>".$car_val->model."</td>";
echo "<td>".$car_val->color."</td>";
echo "<td>".$car_val->release_date."</td>";
echo "<td>".$car_val->value."</td>";
if ($user->data()->type == 1) {
echo
"<td>
<form action='index.php?page=carlist' method='POST'>
<input type='hidden' value='".$car_val->id."' name='id'>
<input type='submit' value='X' class='btn btn-danger'>
</form>
</td>";
}
echo "</tr>";
}
?>
</tbody>
</table>
I used this code but isn't working:
<script>
$('table').filterTable();
</script>
How can I make this plugin to work?

Unable to make the html of the data in the controller and show on the dropdown select

i want to show the restaurant after selecting its area from dropdown list. but my code did not show the restaurant name and the menu button of that restaurant please tell me where i did mistake
This is my view code
<div id="restaurant">
</div>
This is controller code
public function get_rests()
{
$cit_id = $this->input->post('cit_id');
$area = $this->input->post('areaID');
$where = array('city_id'=>$cit_id,'city_area_id'=>$area);
$html = '
<div class="container" id="">
<table align="centre" class="table table-condensed table-striped table-hover no-margin"style="width:70%" id="">
<thread>
<tr style="width: 56%;">
<th>
No.
</th>
<th style="">
Restaurant Names
</th>
</tr>
</thread>
<tbody>
<?php $i=1;foreach($result as $row){
?>
<tr id="<?php echo $row->restaurant_id; ?>" class="res_id">
<th style="">
<?php echo $i++; ?>
</th>
<th style="">
<?php echo $row->restaurant_name; ?>
</th>
<th style="width: 1%" >
</i>See Menu
</th>
</tr>
<?php } ?>
</tbody>
</table>
</div>
';
echo $html;
This is my model code view
function select_record($table, $where = NULL){
$this->db->select();
if($where)
$this->db->where($where);
$this->db->from($table);
$query = $this->db->get();
// echo $this->db->last_query();
return $query->result();
}
Script code
function get_rests(){
var city_id = $('#city_id').val();
var area_id = $("#area_id").val();
$.ajax({
type: "POST",
url: "<?=base_url();?>index.php/Bulk_Controller/get_rests",
data: {cit_id: city_id,areaID: area_id},
dataType: "text",
cache:false,
success:
function(data){
// alert(data);
$('#restaurant').html(data);
}
});
}
You didn't called a model function to get data from your DB Table.
public function get_rests()
{
$cit_id = $this->input->post('cit_id');
$area = $this->input->post('areaID');
$where = array('city_id'=>$cit_id,'city_area_id'=>$area);
$result= $this->your_model->select_record('table_name',$where);
$html = '
<div class="container" id="">
<table align="centre" class="table table-condensed table-striped table-hover no-margin"style="width:70%" id="">
<thread>
<tr style="width: 56%;">
<th>
No.
</th>
<th style="">
Restaurant Names
</th>
</tr>
</thread>
<tbody>
<?php $i=1;foreach($result as $row){
?>
<tr id="<?php echo $row->restaurant_id; ?>" class="res_id">
<th style="">
<?php echo $i++; ?>
</th>
<th style="">
<?php echo $row->restaurant_name; ?>
</th>
<th style="width: 1%" >
</i>See Menu
</th>
</tr>
<?php } ?>
</tbody>
</table>
</div>
';
echo $html;

while loop didnt work

Hi guys, I'm trying to do the while loop.
The while loop will loop through all the orders.
It works but somehow it doesn't while loop through the order status.
For example, order 4 status is pending, but order 5 status shows nothing.
I suspect I placed the brackets wrongly.
This is my code.
<form action="results-action" method="post" enctype="multipart/form-data">
<fieldset>
<table width="600" border="1">
<tr><td><h2>Pending Order</h2></td></tr>
<tr>
<th scope="col">Order ID</th>
<th scope="col">Name</th>
<th scope="col">Address</th>
<th scope="col">Product Name</th>
<th scope="col">Produt Quantity</th>
<th scope="col">Price</th>
<th scope="col">Order status</th>
</tr>
<?php
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><input type="text" value='<?=$row['virtuemart_order_id']?>' name="orderid" id="virtuemart_order_id"></td>
<td><?=$row['first_name']?></td>
<td><?=$row['address_1']?></td>
<td><?=$row['order_item_name']?></td>
<td><?=$row['product_quantity']?></td>
<td><?=$row['product_final_price'] ?></td>
<td><select name="change">
<?php
while ($row2 = mysqli_fetch_array($result2)) {
?>
<option value="<?=$row2['order_status_code'] ?>"><?=$row2['order_status_name'] ?></option>
<?php
} //end inner while
?>
</td>
</tr>
<?php
} //end outer while
?>
</table>
</fieldset>
<fieldset>
<table>
<tr>
<td><input type="submit" value="Update status" name="update status"> </td>
</tr>
</table>
</fieldset>
</form>
If you want to get the same rows every time in the inner while you will have to reset the internal pointer of the mysqli result set. For this, you can use the mysqli_data_seek()
You will end up with something like this:
while ($row = mysqli_fetch_array($result)) {
// snip ...
while ($row2 = mysqli_fetch_array($result2)) {
// snip
}
mysqli_data_seek($result2, 0);
// snip
}
Please also ensure the <select> has unique name, otherwise all your status will be captured wrongly.
<select name="change_<?=$row['row_id']?>">
Something like that.

Categories