Form with download.php - does not work
Form with action with remove.php - works
Am I missing some little thing?
<table id="mytable1" width="80%" class="text-center table table-striped table-bordered table-Responsive ">
<thead>
<th>File Name</th>
<th>File Type</th>
<th>File Size(KB)</th>
<th>Remove</th>
<th>Download</th>
</thead>
</tr>
<?php
while($item = mysql_fetch_array($result1)) {
echo "<tr>";
echo "<td>".$item['file_name']."</td>";
echo "<td>".$item['file_type']."</td>";
echo "<td>".$item['file_size']."</td>";
// this command does not work but the next echo works - why?
echo "<td><form action='download.php' method='GET'><input name='filename' type='hidden' value='".$item['file_name']."'/><button class='btn btn-danger btn-xs' type='submit' value='down'/><span class='glyphicon glyphicon-trash'></span></form></td>";
echo "<td><form action='remove.php' method='GET'><input name='filename' type='hidden' value='".$item['file_name']."'/><button class='btn btn-primary btn-xs' type='submit' value='del'/><span class='glyphicon glyphicon-download'></span></form></td>";
echo "</tr>";
}
echo "</table>";
?>
Related
I need help with a simple task, but I am stuck...
I have a database where I pull different data and I am visualizing those data on a web page.
Here is my query for getting the data:
$result = mysqli_query($mysqli, "SELECT *, DATEDIFF(nextcalibration, CURDATE()) AS days FROM tools AS dp ");
Here is my table:
<table id="table_id" class="table table-striped">
<tr>
<th>Nr</th> <th>Status</th> <th>name</th> <th>Serial</th> <th>Used At</th> <th>Owner</th> <th>Calibrated</th> <th>nextcalibration</th> <th>vendor</th> <th>days</th> <th>actions</th>
</tr>
<?php
while($user_data = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$user_data['toolnr']."</td>";
echo "<td>".$user_data['status']."</td>";
echo "<td>".$user_data['toolname']."</td>";
echo "<td>".$user_data['serial']."</td>";
echo "<td>".$user_data['usedat']."</td>";
echo "<td>".$user_data['owner']."</td>";
echo "<td>".$user_data['calibrated']."</td>";
echo "<td>".$user_data['nextcalibration']."</td>";
echo "<td>".$user_data['vendors']."</td>";
echo "<td>".$user_data['days']. "</td>";
echo "<td><a href='edit.php?id=$user_data[id]'><img src='img/edit.png' ></a> | <a href='delete.php?id=$user_data[id]' onclick='return checkDelete()'><img src='img/delete.png'></a></td></tr>";
}
?>
</table>
I would like to make conditional formatting only for the last column - "days".
The idea is if the value of "days" <= 30 to become red color text.
I tried with various JS, but honestly, it did not work.
<table id="table_id" class="table table-striped">
<tr>
<th>Nr</th> <th>Status</th> <th>name</th> <th>Serial</th> <th>Used At</th> <th>Owner</th> <th>Calibrated</th> <th>nextcalibration</th> <th>vendor</th> <th>days</th> <th>actions</th>
</tr>
<?php
while($user_data = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$user_data['toolnr']."</td>";
echo "<td>".$user_data['status']."</td>";
echo "<td>".$user_data['toolname']."</td>";
echo "<td>".$user_data['serial']."</td>";
echo "<td>".$user_data['usedat']."</td>";
echo "<td>".$user_data['owner']."</td>";
echo "<td>".$user_data['calibrated']."</td>";
echo "<td>".$user_data['nextcalibration']."</td>";
echo "<td>".$user_data['vendors']."</td>";
echo "<td>";
$days=$user_data['days'];
if($days <= 30){
echo "<span style='color:red;'>$days</span>";
}else{
echo $days;
}
echo "</td>";
echo "<td><a href='edit.php?id=$user_data[id]'><img src='img/edit.png' ></a> | <a href='delete.php?id=$user_data[id]' onclick='return checkDelete()'><img src='img/delete.png'></a></td></tr>";
}
?>
</table>
Would something simple like this - without JS- work?
<table id="table_id" class="table table-striped">
<tr>
<th>Nr</th> <th>Status</th> <th>name</th> <th>Serial</th> <th>Used At</th> <th>Owner</th> <th>Calibrated</th> <th>nextcalibration</th> <th>vendor</th> <th>days</th> <th>actions</th>
</tr>
<?php
while($user_data = mysqli_fetch_array($result))
{
$style_days=($user_data['days']<=30)?'style="color:red"':'';
echo "<tr>";
echo "<td>".$user_data['toolnr']."</td>";
echo "<td>".$user_data['status']."</td>";
echo "<td>".$user_data['toolname']."</td>";
echo "<td>".$user_data['serial']."</td>";
echo "<td>".$user_data['usedat']."</td>";
echo "<td>".$user_data['owner']."</td>";
echo "<td>".$user_data['calibrated']."</td>";
echo "<td>".$user_data['nextcalibration']."</td>";
echo "<td>".$user_data['vendors']."</td>";
echo "<td ".$style_days.">".$user_data['days']. "</td>";
echo "<td><a href='edit.php?id=$user_data[id]'><img src='img/edit.png' ></a> | <a href='delete.php?id=$user_data[id]' onclick='return checkDelete()'><img src='img/delete.png'></a></td></tr>";
}
?>
</table>
Of course, apply the necessary guarding for $user_data['days'] (existence, numeric..) :)
I am trying to print a table with the list of customer oder from data retrieved from an xml file. I think my attempt at retrieving data has failed as it did not show anything. I also wanted to add two buttoms at the end of each order (delet and edit):
<?php
// Loading the XML file
$xml = simplexml_load_file("database/orderlist.xml");
echo "
<div style='overflow-x:auto;'>
<table id='order'>
<tr>
<th>Order #</th>
<th>Customer ID# </th>
<th>Items</th>
<th>Total Prices (CND)</th>
</tr>
foreach($xml->children() as $ftpxml)
{
echo '<td>".$ftpxml->attributes()->id."</td>';
echo '<td> ".$ftpxml->attributes()->customerID." </td>';
echo '<td>".$ftpxml->attributes()->products." </td>';
echo '<td>".$ftpxml->attributes()->totalprice." </td>';
echo '<a href="backStoreOrderProfile.html" ><button class="btn Edit" id="btn" input value="Check" type=submit > Edit </button></a>';
echo '<button class="btn Delete" id="btn" input value="Check" type=submit > Delete</button></td>';
}
</table>
</div>
";
?>
You have a number of problems in your codes
make sure you end each php statement by a semi-colon
make sure you enclose the string in same quotation marks
make sure you traverse the XML hierarchy properly
<?php
// Loading the XML file
$xml = simplexml_load_file("database/orderlist.xml");
echo "
<div style='overflow-x:auto;'>
<table border=1 cellpadding=5 id='order' style='border-collapse: collapse;' bordercolor='#DDDDDD'>
<tr>
<th>Order #</th>
<th>Customer ID# </th>
<th>Items</th>
<th>Total Prices (CND)</th>
<th>Edit
<th>Delete
</tr>";
foreach ($xml->oder as $ftpxml) {
?>
<tr>
<td><?php echo $ftpxml->id; ?>
<td><?php echo $ftpxml->customerID; ?>
<td>
<?php
foreach ($ftpxml->products->product as $ftpxml2) {
echo $ftpxml2->productName . " ";
} ?>
<td>
<?php echo $ftpxml->totalprice; ?>
<?php
echo '<td><a href="backStoreOrderProfile.html" ><button class="btn Edit" id="btn" input value="Check" type=submit > Edit </button></a>';
echo '<td><button class="btn Delete" id="btn" input value="Check" type=submit > Delete</button></td>';
?>
<?php
} ?>
I am working on a project and I got a small problem.I want to display a request to an owner which is stored in a table in mySQL.The first entry is fine.But the second entry comes next to the first entry instead of below.So it seems like this
Header Header Header Header
value value value value 2ndvalue 2ndvalue 2ndvalue 2ndvalue.
How can I fix this and put the 2nd values below the respective headers and value.Here is my code
<table border='1' cellpadding='5'>"
<title>View Incoming Orders</title>
<tr> <th>Restaurant Name</th>
<th>Customer</th>
<th>Order Date</th>
<th>Details</th>
<th>Cost</th>
<th>is Processed</th>
<th> Finalize Order </th>
<th> Delete </th>
</tr>
<tr>
<?php
$length=count($restaurantNames);
for($c=0; $c<$length; $c++){
$custDate=$customers[$c]. "/".$orderDates[$c];
echo "<td> $restaurantNames[$c]</td>";
echo "<td> $customers[$c]</td>";
echo "<td> $orderDates[$c]</td>";
echo "<td> $detailss[$c]</td>";
echo "<td> $costs[$c]</td>";
echo "<td> $isProcesseds[$c]</td>";
echo "<td><input type='checkbox' name='check_list[]' value='$custDate' />Finalize Order </td>";
echo "<td><input type='checkbox' name='check_list2[]' value='$custDate' />Delete </td>";
}
?>
</tr>
<tr><input type="submit" id="update" name="update" value="Update"></input></tr>
</table>
try moving your tr into the loop instead of outside of it. Also title is not valid for how you are using it. It is meant for the title tag of the website in head
<table border='1' cellpadding='5'>"
<title>View Incoming Orders</title>
<tr> <th>Restaurant Name</th>
<th>Customer</th>
<th>Order Date</th>
<th>Details</th>
<th>Cost</th>
<th>is Processed</th>
<th> Finalize Order </th>
<th> Delete </th>
</tr>
<?php
$length=count($restaurantNames);
for($c=0; $c<$length; $c++){
echo "<tr>";
$custDate=$customers[$c]. "/".$orderDates[$c];
echo "<td> $restaurantNames[$c]</td>";
echo "<td> $customers[$c]</td>";
echo "<td> $orderDates[$c]</td>";
echo "<td> $detailss[$c]</td>";
echo "<td> $costs[$c]</td>";
echo "<td> $isProcesseds[$c]</td>";
echo "<td><input type='checkbox' name='check_list[]' value='$custDate' />Finalize Order </td>";
echo "<td><input type='checkbox' name='check_list2[]' value='$custDate' />Delete </td>";
echo "</tr>";
}
?>
<tr><input type="submit" id="update" name="update" value="Update"></input></tr>
</table>
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?
I try to output a database Table in PHP within a HTML Table. When I view the output in HTML, It is totally messed up. In my opinion everything is correct. Maybe someone of you see the mistake.
My PHP file:
<table id="table_id" class="display table table-hover table-responsive table-striped">
<thead>
<tr>
<th class="col-md-3">Gespeichert am</th>
<th class="col-md-5">Text</th>
<th class="col-md-3">Kategorie</th>
<th class="col-md-1"><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></th>
</tr>
</thead>
<tbody>
<?php
while($row=mysql_fetch_object($ergebnis))
{
echo "<tr>";
echo "<td>".date("H:i - d.m.y",strtotime($row->Zeit) + 60*60)."</td>";
echo "<td><a href='".$row->url."' target='_blank'>".$row->text."</a></td>";
echo "<td>".$row->kategorie."</td>";
echo "<form action='delete.php' method='post'>";
echo "<td>";
echo "<input type='hidden' name='delete_id' value='".$row->id."'</td>";
echo "<button onClick='submit();' style='border:none; background-color:transparent; padding:0px;' type='submit' value='Delete'><span class='glyphicon glyphicon-remove delete' aria-hidden='true'></span></button>";
echo "</td>";
echo "</form>";
echo "</tr>";
}
?>
</tbody>
</table>
My output in HTML looks like this:
<table id="table_id" class="display table table-hover table-responsive table-striped">
<thead>
<tr>
<th class="col-md-3">Gespeichert am</th>
<th class="col-md-5">Text</th>
<th class="col-md-3">Kategorie</th>
<th class="col-md-1"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>15:46 - 26.03.15</td>
<td>Google link</td>
<td>Web</td>
<form action="delete.php" method="post"></form>
<td><input type="hidden" name="delete_id" value="37" <="" td="">
<button onclick="submit();" style="border:none; background-color:transparent; padding:0px;" type="submit" value="Delete">
<span class="glyphicon glyphicon-remove delete" aria-hidden="true"></span>
</button>
</td>
</tr>
</tbody>
</table>
Either put <form> inside cell of table (inside the <td>), or wrap it around entire table.
The problem is that <tr> allows only <th> and <td> nodes inside and that's why your <form> is getting messed up.
Also, as someone already mentioned in comments, the following line has errors which result in broken html:
echo "<input type='hidden' name='delete_id' value='".$row->id."'</td>";
should be:
echo "<input type='hidden' name='delete_id' value='".$row->id."'></td>";