How to hide table row? - php

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>

Related

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>

How to create an html link to another page from "<?=$objResult["id"];?>"

I'm working on a php/mysql application and need to make the output of one column, one row an html link to another html page. Have not been able to find any relavant information. The "" needs to be the link. Thanks for any help.
<table id="display" style="width:800px;">
<tr>
<th width="40">ID</th>
<th width="70">Last</th>
<th width="70">First</th>
<th width="10">Middle</th>
<th width="70">Birth</th>
<th width="70">Death</th>
<th width="170">Notes</th>
<th width="100">Cemetery</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td style='text-align:center;'><?=$objResult["id"];?></td>
<td style='text-align:center;'><?=$objResult["last"];?></td>
<td style='text-align:center;'><?=$objResult["first"];?></td>
<td style='text-align:center;'><?=$objResult["middle"];?></td>
<td style='text-align:center;'><?=$objResult["birth"];?></td>
<td style='text-align:center;'><?=$objResult["death"];?></td>
<td><?=$objResult["notes"];?></td>
<td style='text-align:center;'><?=$objResult["cemetery"];?></td>
</tr>
<?
}
?>
</table>

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.

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