Php help to remove remove td line - php

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>

Related

How can I display values from a table that correspond to their matching id

So in this query below im joining two tables through order_id and displaying the all the values from the user_orders table.
As per the image below I am trying to display only the order_Id rows that match the order_manager table.
public function getUserOrder(){
$sql = "SELECT user_orders.order_id,
user_orders.title, user_orders.price,
user_orders.quantity
FROM order_manager
JOIN user_orders ON order_manager.order_id = user_orders.order_id;";
$stmt = $this->connect()->prepare($sql);
$stmt->execute();
while ($result = $stmt->fetchAll()){
return $result;
}
}
I have attempted to use an if statement that appears to do something however it gives me the values that don't match order id in reverse.
<div class="container mt-5">
<?php $artworks = new Artworks(); ?>
<div class="row">
<div class="col-lg-12">
<table class="table table-dark">
<thead>
<tr>
<th scope="col">Order ID</th>
<th scope="col">Full Name</th>
<th scope="col">Phone</th>
<th scope="col">Address</th>
<th scope="col">Orders</th>
</tr>
</thead>
<?php
$artworks->getOrder();
foreach ($artworks->getOrder() as $art) {
echo "<tbody>
<tr>
<td>$art[order_id]</td>
<td> $art[full_name]</td>
<td> $art[phone] </td>
<td>$art[address]</td>
<td>
<table class= 'tale text-center table-dark'>
<thead>
<tr>
<th scope='col'>Order ID</th>
<th scope='col'>title</th>
<th scope='col'>price</th>
<th scope='col'>Quantity</th>
</tr>
<thead>
<tbody>
<tr>";
$artworks->getUserOrder();
foreach ($artworks->getUserOrder() as $order) {
if ($order['order_id'] == $art['order_id']) {
echo "<td>$order[order_id]</td>";
}
echo "
<td>$order[title]</td>
<td>$order[price]</td>
<td>$order[quantity]</td>
</tr>";
}
echo "
</tbody>
</table>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
Here is an image to help explain the desired output
Solved moving the td items into the if statement. Guess it was mostly correct.
$artworks->getUserOrder();
foreach($artworks->getUserOrder() as $order)
{
if ($order['order_id'] == $art['order_id']) {
echo "<td>$order[order_id]</td>";
echo "
<td>$order[title]</td>
<td>$order[price]</td>
<td>$order[quantity]</td>
</tr>
";
}
}

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>

How to convert Html code to template output in browser

I need to convert HTML in template.
As seen in image content should show as a template.
I am using table to show . but now i need to show it in template output
Here is my Code:
<table id="datatable" class="tablesorter">
<span id='errfrmMsg'></span>
<thead>
<tr>
<th scope="col" id="">Name</th>
<th scope="col" id="">Content</th>
</tr>
</thead>
<tbody>
<?php
$templ_id = $_REQUEST['templ_id'];
$getTemplateQuery = mysql_query("select * from templates where id = $templ_id");
$getTemplateRow = mysql_fetch_array($getTemplateQuery);
?>
<tr>
<td valign="top" width="125"><?php echo $getTemplateRow['templ_name'];?></td>
<td valign="top" width="319">
<?php
echo $templContent = $getTemplateRow['templ_content'];
?>
</tr>
</tbody>
</table>
Here is an Output:
From what I can gather from your question, try outputting with:
$html = htmlspecialchars_decode($content)
EDIT:
echo $templContent = htmlspecialchars_decode($getTemplateRow['templ_content']);
Try this this will help You
<?php
echo $htmlContent = htmlspecialchars_decode($getTemplateRow['templ_content'])
?>

Data in table not displaying the way I want it to

I have a spinner and what happens is that whatever number is in the spinner, when the form is submitted, it should display the word "quest" as many times as the number in the spinner.. E.g if number in spinner is 3, then it will display "quest" 3 times in the table.
The problem is displaying it in the table.
At the moment with my current code it is displaying it like this:
quest
quest
quest
Question Id, Option Type, Duration .... These are table headings
It is displaying the words quest outside the table
Instead I want the word "quest" to be displayed in the Question Id column like this:
Question Id, Option Type, Duration...
quest
quest
quest
How can I get it to display it like the example above?
Below is code
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) {
echo "<tr>quest";
}
}
?>
<td class='qid'></td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
</table>
I did try echo "<td class='qid'></td>"; but this completely failed as well
Try this:
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) {
?>
<tr>
<td class='qid'><?php echo $quest; ?></td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
<?php
} // For
} // If
?>
</table>
Is this what you want to do? Display "quest" in the first column?
<table border=1 id="qandatbl" align="center">
<tr>
<th class="col1">Question No</th>
<th class="col2">Option Type</th>
<th class="col1">Duration</th>
<th class="col2">Weight(%)</th>
<th class="col1">Answer</th>
<th class="col2">Video</th>
<th class="col1">Audio</th>
<th class="col2">Image</th>
</tr>
<?php
$spinnerCount = $_POST['txtQuestion'];
if($spinnerCount > 0) {
for($i = 1; $i <= $spinnerCount; $i++) { ?>
<tr>
<td class='qid'>quest</td>
<td class="options"></td>
<td class="duration"></td>
<td class="weight"></td>
<td class="answer"></td>
<td class="video"></td>
<td class="audio"></td>
<td class="image"></td>
</tr>
<?php
}
}
?></table>
?>

Tablesorter plugin not sorting my tables when data comes from database

I have the following code:
<table id="box-table-a" class="tablesorter">
<thead>
<tr>
<th scope="col">B-House/Dorm Name</th>
<th scope="col">Address</th>
<th scope="col">Price Range</th>
<th scope="col">Date Added</th>
<th scope="col">Status</th>
</tr>
</thead>
<?php
$q=mysql_query("select * from property");
while( $f=mysql_fetch_array($q, MYSQL_ASSOC))
{ $p_id=$f["p_id"];
echo"
<tbody>
<tr>
<td onblurr='hover2()' onmouseover='hover(".$p_id.")' onclick='showUser(".$p_id.")'>
<span style='cursor:pointer'>".$f['p_name']."</span></td>
<td id='pretty'>".$f['address']."</td>
<td>".$f['p_name']."</td> <td>".$f['payment_type']."</td> <td>".$status."</td> </tr>
</tbody>
";
}
?>
</table>
Any idea what may be wrong here?
Don't add <tbody></tbody> to every loop in the while! Tablesorter is very sensitive.
You did'nt sort your DB :
$q=mysql_query("select * from property ORDER BY p_name");

Categories