i have that table and a div with a quicksearch and after i write 2 or 3 letters he show results, but then the div search dissapear after show the results and if i want to write something new, i have to refresh the page
thats the div
<table id="tabela" class="table admin">
<tr class="outro">
<th width="15%">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.quicksearch/2.3.1/jquery.quicksearch.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="form-group input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
<input name="consulta" id="txt_consulta" placeholder="Procurar..." type="text" class="form-control">
</div>
</th>
<th width="10%"></th>
<th width="30%"></th>
<th width="15%">
<img src="../assets/img/add.PNG" class="icone" />Adicionar utilizador
</a>
</th>
</tr>
<tr class="tabela">
<th width="10%">
<p>Nome</p>
</th>
<th width="5%"></th>
<th width="30%">
<p>Permissões</p>
</th>
<th width="10%"></th>
</tr>
<?php
foreach ($utilizadores as $key => $value) {
echo '<tr><td>' . '<p class="texto">' . $value->nome . '</p>' . '</td>';
echo '<td>' . '<button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">' . '<p>Info</p>' . '</button></td>';
echo '<td>';
if ($value->tipo_user == "1") {
echo '<p class="texto">' . "Administrador" . '</p>';
} else if ($value->tipo_user == "2") {
echo '<p class="texto">' . "Gestor" . '</p>';
} else {
echo '<p class="texto">' . "Utilizador" . '</p>';
}
'</td>';
echo '<td>Eliminar</p></td></tr>';
}
?>
</table>
and thats the script
<script>
$('input#txt_consulta').quicksearch('table#tabela tbody tr');
</script>
what am i doing wrong?
It's because your quicksearch filters all rows of your table. You can solve that by giving your dynamically added rows a class and set quicksearch upon that class.
echo '<tr class="filter_row"><td>' . '<p class="texto">' . $value->nome . '</p>' . '</td>';
and then you have to add that to the configuration script:
<script>
$('input#txt_consulta').quicksearch('table#tabela tbody tr.filter_row');
</script>
Related
I have the following html code:
<table class="table table-sm table-bordered table-striped table-hover display">
<thead class="text-center align-middle sticky-top">
<tr>
<th>NO</th>
<th>DETAILS</th>
<th>MODEL</th>
<th>PIC</th>
<th>OPEN DATE</th>
<th>TARGET DATE</th>
<th colspan="3">UPDATE</th>
<th class="d-none">FLOOR</th>
<th>CATEGORY</th>
<th>CREATED BY</th>
<th>ACTION</th>
</tr>
</thead>
<tbody class="table-group-divider" style="font-size:0.9rem;">
<tr>
<td>' . $number++ . '</td>
<td>' . $row["momdetails"] . '</td>
<td class="text-center">' . $row["model"] . '</td>
<td class="text-center">' . $row["pic"] . '</td>
<td class="text-center">' . $row["opendate"] . '</td>
<td class="text-center">' . $row["targetdate"] . '</td>
<td colspan="3">
<div class="updateColumn">
<span style="font-weight: bold;">Remarks: </span>' . $row1["remarks"] . '
<span style="font-weight: bold;">Updated on: </span>' . $row1["updatedate"] . '
<br><span style="font-weight: bold;">By: </span>' . $row1["updateby"] . '<br>
<hr style="height:2px;border-width:0;color:black;background-color:black">
</div>
</td>
<td class="text-center d-none">' . $row["floor"] . '</td>
<td class="text-center">' . $row["category"] . '</td>
<td class="text-center">' . $row["username"] . '</td>
<td class="text-center">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown"
aria-expanded="false">
Action
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item text-dark" href="#" onclick="updateMoM(' . $row[" momid"] . ')">Update</a></li>
<li><a class="dropdown-item text-dark" href="#" onclick="updateToUM(' . $row["momid"] . ')">Under Monitoring</a></li>
<li><a class="dropdown-item text-dark" href="#" onclick="updateToClosed(' . $row["momid"] . ')">Close</a></li>
<li><a class="dropdown-item text-dark" href="#" onclick="updateToCancelled(' . $row["momid"] . ')">Cancel</a></li>
<li><a class="dropdown-item text-dark" href="#" onclick="email(' . $row["momid"] . ')">Email</a></li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
I want the "UDPATE" column to be scrollable when it exceeds 300px but also expands in height following the tallest column in the row. I tried putting style="overflow-y: scroll; max-height:300px" for the class updateColumn which did make it scrollable but the height is stuck at 300px when there's another column that's taller than 300px. Like this:
What modification should I make?
I have created a shortcode which renders this table on the frontend. At the moment the shortcode puts the content at the top of the page rather than respecting the location of where the shortcode is pasted in the editor.
How can i fix this?
<div id="cookie-container">
<div class="row justify-content-center mb-3">
<div class="col-12">
<h3>Essential Cookies</h3>
</div>
</div>
<table class="table table-bordered table-hover table-sm diva-cookie-table">
<thead class="diva-cookie-table__thead">
<tr>
<th style="width: 33%" class="diva-cookie-table__th">Name</th>
<th style="width: 33%" class="diva-cookie-table__th">Cookie</th>
<th style="width: 33%" class="diva-cookie-table__th">Purpose</th>
</tr>
</thead>
<tbody class="diva-cookie-table__tbody">
<tr>
<?php
$essential_cookies = carbon_get_theme_option( 'essential_cookies' );
foreach ( $essential_cookies as $cookie ) {
echo '<tr>';
if($cookie['name']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['name'];
echo '</td>';
}
if($cookie['cookies']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['cookies'];
echo '</td>';
}
if($cookie['usage']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['usage'];
echo '</td>';
}
}
echo '</tr>';
?>
</tr>
</tbody>
</table>
</div>
/**
* Construct Essential Cookies Shortcode
*/
function construct_essential_cookies_table()
{
ob_start();
include dirname( __FILE__ ) . '/partials/essential_cookie_table.php';
return ob_get_clean();
}
add_shortcode('diva_essential_cookies', 'construct_essential_cookies_table');
You need to include the full HTML code inside the php output buffer functions like that.
<?php ob_start(); ?>
<div id="cookie-container">
<div class="row justify-content-center mb-3">
<div class="col-12">
<h3>Essential Cookies</h3>
</div>
</div>
<table class="table table-bordered table-hover table-sm diva-cookie-table">
<thead class="diva-cookie-table__thead">
<tr>
<th style="width: 33%" class="diva-cookie-table__th">Name</th>
<th style="width: 33%" class="diva-cookie-table__th">Cookie</th>
<th style="width: 33%" class="diva-cookie-table__th">Purpose</th>
</tr>
</thead>
<tbody class="diva-cookie-table__tbody">
<tr>
<?php
$essential_cookies = carbon_get_theme_option( 'essential_cookies' );
foreach ( $essential_cookies as $cookie ) {
echo '<tr>';
if($cookie['name']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['name'];
echo '</td>';
}
if($cookie['cookies']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['cookies'];
echo '</td>';
}
if($cookie['usage']) {
echo '<td class="diva-cookie-table__title">';
echo $cookie['usage'];
echo '</td>';
}
}
echo '</tr>';
?>
</tr>
</tbody>
</table>
</div>
<?php return ob_get_clean();
I'm building a forum using php and bootstrap. It works 100%, my only issue is when a user posts in a thread, the post and the user profile images has a big gap. It looks like a padding issue, but there is not padding between them. Any advice would be brilliant
echo '<div class="container form">
<div class="page-header page-heading">
<tr class="text-center">
<th colspan="2"><h2>' . $row['topic_subject'] . '</h2></th>
</tr>
<table class="table forum table-striped table-hover">
<thead>
<tr>
<th class="cell-stat"></th>
</tr>
</thead/>';
//fetch the posts from the database
$posts_sql = "SELECT
posts.post_topic,
posts.post_content,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_topic = " . mysql_real_escape_string($_GET['id']);
$posts_result = mysql_query($posts_sql);
if(!$posts_result)
{
echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>';
}
else
{
while($posts_row = mysql_fetch_assoc($posts_result))
{
echo '
<tbody>
<tr>
<td class="text-center">
</td>
<td class="hidden-xs hidden-sm">
<img src="ppp.png"><br>
<i class="fa fa-clock-o">
</i>
<ul class="pull-left user-info">
<li>'
.$posts_row['user_name'].
'</li>'.
'<li>'
. date('d-m-Y H:i', strtotime($posts_row['post_date'])).
'</li>
</td>
<td class="pull-right">'.
'<p>'
.htmlentities(stripslashes($posts_row['post_content'])).
'</p>
</td>
</tr>';
}
}
if(!$_SESSION['signed_in'])
{
echo '<tr><td colspan=2>You must be signed in to reply. You can also sign up for an account.';
}
else
{
//show reply box
echo '<tr><td colspan="2"><h2>Reply:</h2><br />
<form method="post" action="reply.php?id=' . $row['topic_id'] . '">
<textarea name="reply-content"></textarea><br /><br />
<input type="submit" value="Submit reply" />
</form></td></tr>';
}
//finish the table
echo '</thead></table>';
}
}
I think the gap might be as a result pull-right applied on the table
<td class="pull-right">'.
'<p>'
.htmlentities(stripslashes($posts_row['post_content'])).
'</p>
</td>
You might want to remove it completely. If not, try applying pull-left to the paragraph instead of table
<td >'.
'<p class="pull-left">'
.htmlentities(stripslashes($posts_row['post_content'])).
'</p>
</td>
I'm using SB Admin Bootstrap.
My table didn't functioning as it should be (should be user can search the data in table and data arranged well), but :
This is my php code:
<div class="box-content">
<?php
if ($result) {
?>
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th class="text-left">User ID</th>
<th class="text-left">Username</th>
<th class="text-left">Password</th>
<th class="text-left">Full Name</th>
<th class="text-left">Task</th>
</tr>
</thead>
<?php
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '
<tbody>
<tr>
<td class="center">' . $row['userid'] . '</td>
<td class="center">' . $row['username'] . '</td>
<td class="center">' . $row['password'] . '</td>
<td class="center">' . $row['fullname'] . '</td>
<td class="center">
<a class="btn btn-success" href="#">
<i class="halflings-icon white zoom-in"></i>
</a>
<a class="btn btn-info" href="#">
<i class="halflings-icon white edit"></i>
</a>
<a class="btn btn-danger" href="#">
<i class="halflings-icon white trash"></i>
</a>
</td>
</tr>
</tbody>';
}}
?>
</table>
</div>
Answer moved from comment
You are repeating <tbody> element, so script are just taking first occurrence of this tag and executing some functions, leaving every further <tbody> intact.
Move out of loop, it must be unique in table.
Got 2 questions regarding a table which output is below:
Question 1:
The table height is 500px, yet what I don't understand is that it looks like the content underneath which doesn't belong to the table is displayed within the table because of the scroll bar that goes so that down that it looks like the content underneath the table rows are in the table. So my question is how can I get the scroll bar to appear only if the 500px is met, rather than showing it straight away as it is doing now? How do I get the content (select box, heading, etc) be displayed underneath the table rather than in the table as it is doing in the screenshot
Question 2:
How can I get the scroll bar to be clipped on the side of the table? At the moment it is clipped just underneath the last column meaning it is taking up some of the last column's space and hence why table columns are not matching.
Below is html code of table:
<table id="tableqanda" align="center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th width="30%" class="question">Question</th>
<th width="8%" class="option">Option Type</th>
<th width="6%" class="noofanswers">Number of Answers</th>
<th width="8%" class="answer">Answer</th>
<th width="6%" class="noofreplies">Number of Replies</th>
<th width="6%" class="noofmarks">Number of Marks</th>
<th width="12%" class="images">Images</th>
</tr>
</thead>
</table>
<div id="tableqanda_onthefly_container">
<table id="tableqanda_onthefly" align="center" cellpadding="0" cellspacing="0">
<tbody>
<?php
foreach ($arrQuestionContent as $key=>$question) {
echo '<tr class="tableqandarow">'.PHP_EOL;
echo '<td width="30%" class="question">'.htmlspecialchars($question).'</td>' . PHP_EOL;
echo '<td width="8%" class="option">'.htmlspecialchars($arrOptionType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofanswers">'.htmlspecialchars($arrNoofAnswers[$key]).'</td>' . PHP_EOL;
echo '<td width="8%" class="answers">'.htmlspecialchars($arrAnswer[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofreplies">'.htmlspecialchars($arrReplyType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofmarks">'.htmlspecialchars($arrQuestionMarks[$key]).'</td>' . PHP_EOL;
echo '<td width="12%" class="images">'.htmlspecialchars($arrImageFile[$key]).'</td>' . PHP_EOL;
echo '</tr>'.PHP_EOL;
}
?>
</tbody>
</table>
<h4>PARTICIPATING STUDENTS</h4>
<p>
<strong>Number of Participating Students:</strong> <?php echo $studentnum; ?>
</p>
<p>
<strong>Current Participating Students:</strong>
<br/>
<tr>
<td>
<select name="students" id="studentslist" size="10">
<?php
if($studentnum == 0){
echo "<option disabled='disabled' class='red' value=''>No Students currently in this Assessment</option>";
}else{
while ( $currentstudentstmt->fetch() ) {
echo "<option disabled='disabled' value='$dbStudentId'>" . $dbStudentAlias . " - " . $dbStudentForename . " " . $dbStudentSurname . "</option>" . PHP_EOL;
}
}
?>
</select>
</p>
Below is CSS:
#tableqanda_onthefly_container
{
width:100%;
overflow-y: scroll;
overflow-x: hidden;
max-height:500px;
}
#tableqanda_onthefly
{
width:100%;
overflow:auto;
clear:both;
}
#tableqanda, #tableqanda_onthefly{
border:1px black solid;
border-collapse:collapse;
table-layout:fixed;
}
#tableqanda{
width:100%;
margin-left:0;
float:left;
}
#tableqanda td {
vertical-align: middle;
border:1px black solid;
border-collapse:collapse;
}
#tableqanda th{
border:1px black solid;
border-collapse:collapse;
text-align:center;
}
I want my table to remain as a scrolling table with fixed headers
UPDATE
For question 1, try setting the overflow-y property to auto. This way the scrollbar will only be displayed once the table exceeds 500px in height.
So something like:
overflow-y:auto;
instead of
overflow-y:scroll;
ORIGINAL POST:
To answer your second question, you can just add the heads of the table as another row:
<div id="tableqanda_onthefly_container">
<table id="tableqanda_onthefly" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="30%" class="question">Question</th>
<th width="8%" class="option">Option Type</th>
<th width="6%" class="noofanswers">Number of Answers</th>
<th width="8%" class="answer">Answer</th>
<th width="6%" class="noofreplies">Number of Replies</th>
<th width="6%" class="noofmarks">Number of Marks</th>
<th width="12%" class="images">Images</th>
</tr>
<?php
foreach ($arrQuestionContent as $key=>$question) {
echo '<tr class="tableqandarow">'.PHP_EOL;
echo '<td width="30%" class="question">'.htmlspecialchars($question).'</td>' . PHP_EOL;
echo '<td width="8%" class="option">'.htmlspecialchars($arrOptionType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofanswers">'.htmlspecialchars($arrNoofAnswers[$key]).'</td>' . PHP_EOL;
echo '<td width="8%" class="answers">'.htmlspecialchars($arrAnswer[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofreplies">'.htmlspecialchars($arrReplyType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofmarks">'.htmlspecialchars($arrQuestionMarks[$key]).'</td>' . PHP_EOL;
echo '<td width="12%" class="images">'.htmlspecialchars($arrImageFile[$key]).'</td>' . PHP_EOL;
echo '</tr>'.PHP_EOL;
}
?>
</table>
</div>
This way the scroll bar should be put at the very right, not underneath anything. The reason it wasn't before was because you had two different tables with independent widths.