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>
Related
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>";
?>
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?
My PHP and HTML code is used to get data from a MySQL database and display it in a table run through a while loop, however there are random semicolons being output before the table tag starts and the h3 tag ends (seen through inspect element in browser). The number of semicolons outputted matches the number of rows from the SQL query.
echo "<form action='predictions.php' method='POST'>";
echo "<h3>" . $date[0] . "</h3>
<table>
<tr>
<col width='100'>
<col width='50'>
<col width='50'>
<col width='100'>
<col width='70'>
<col width='100'>
<th>Home <br> Team</th>
<th>Home <br> Score</th>
<th>Away <br> Score</th>
<th>Away <br> Team</th>
<th>Match <br> Time </th>
<th>First <br> Scorer </th>
</tr>";
while($row = mysqli_fetch_row($match) and $matchid = mysqli_fetch_array($sqlmatchid)){
if ($date[0] != $row[3]) {
echo "</table>";
echo "<hr>";
$date[0] = $row[3];
echo "<h3>".$date[0]."</h3>
<table>
<tr>
<col width='100'>
<col width='50'>
<col width='50'>
<col width='100'>
<col width='70'>
<col width='100'>
<th>Home <br> Team</th>
<th>Home <br> Score</th>
<th>Away <br> Score</th>
<th>Away <br> Team</th>
<th>Match <br> Time </th>
<th>First <br> Scorer </th>
</tr>";
}
echo "<tr>";
echo "<td>" . $row[0] . "</td>" ?>
<td> <input id='phs' type='text' name=<?php echo "phs".$matchid['MatchID'] ?> size='1' maxlength='1'> </td>
<td> <input id='pas' type='text' name=<?php echo "pas".$matchid['MatchID'] ?> size='1' maxlength='1'> </td>
<?php
$smatchid = $matchid['MatchID']; //match id to find scorer
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>" ?>
<td> <select id="scorer" name=<?php echo "scorer".$matchid['MatchID'] ?>>
<option> </option>
<?php
$result = mysqli_query($con,"SELECT PlayerName
FROM players, matches
WHERE matches.MatchID = '$smatchid' AND (players.TeamID = matches.HTeamID OR players.TeamID = matches.ATeamID)");
while ($row = mysqli_fetch_row($result)){
echo "<option> $row[0] </option>";
}
?>
</select> </td>;
<?php
echo "</tr>";
}
I don't understand why these semicolons are appearing and want to remove them.
The semicolon is coming because you have written </select> </td>;. Semicolon after </td> generating it every time. Remove it from there.
I have a PHP based website for jobs. I echo all the jobs from database in a table below. When i click on a job in table row it shows the job details in an iframe beside the table.
This is the code of the table and iframe index.php
<table class="table1">
<tr>
<td colspan="3">
<?php
include "job.header.php";
?>
</td>
</tr>
<tr>
<td width="30%">
<div>
<?php
require "module/job.call.php";
?>
</div>
</td>
<td width="60%">
<iframe name="content" src="../module/job.unclicked.php">
</iframe>
</td>
<td width="20%"> </td>
</tr>
</table>
This is the code that i call jobs from the database job.call.php
<?php
$result = mysqli_query($conn,"SELECT * FROM job where approved='1' ORDER BY `CreatedTime` DESC");
echo "<table id='maintable' class='table-fill' border='0' cellpadding='0' cellspacing='0'>
<tr>
<th position='fixed' overflow='hidden' width='10%'>Job Title</th>
<th position='fixed' width='5%'>Company Name</th>
<th width='5%'>Closing Date</th>
</tr>";
while($row = mysqli_fetch_array($result) ) {
if (strlen($row['positiontitle']) > 20)
$row['positiontitle'] = substr($row['positiontitle'], 0, 60) . "...";
echo "<tr ref='job.details.php?id=".$row['id']."' target='content' class='positiontitle-link'>";
echo "<td><font style='text-shadow: none;'>" . $row['positiontitle'] . "</font></a></td>";
echo "<td>" . $row['companyname'] . "</td>";
echo "<td>" . $row['closingdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
I want that when i click on the job in the table row then the address bar should take the id of the job. because if someone wants to share the job then they should just send that address for specific job.
Now it show like this
I want that it should look like this
I have a table in my DB which I call to show everything in that table on a page one of the items in the table is an image which when moused over needs to show a popup showing data from a separate table which corresponds to that item. I have a JQuery which calls the data depending on the row from the 1st table but when I try to actually put the two together I get the first table showing fine but now I get no pop up on mouseover.
This page is currently included in the index.php page which has the scripts to call the .js / .css files.
Here's the code for what I am trying to do:
<html>
<table border='0' cellpadding='0' cellspacing='0' class="center2">
<tr>
<td width='60'><img src="images/box_tl.png"></td>
<td style="background: url(images/box_tm.png)" align="center"><img src="images/news.png"></td>
<td width='25'><img src="images/box_tr.png"></td>
</tr>
<tr>
<td style="background: url(images/box_ml.png)"><h2>.</h2></td>
<td style="background: url(images/box_mm.png)">
<?php
include 'connect.php';
$query = mysql_query("SELECT * FROM tbl_img") or die(mysql_error());;
echo "<table border='0' cellpadding='1' cellspacing='1' width'90%' id='1' class='tablesorter'><thead>";
echo "<tr> <th> </th> <th>Mob Name</th> <th>Id</th> <th>Health</th> <th>Body</th> <th>Effects</th> <th>Spawn</th></tr></thead><tbody>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $query )) {
$mob_id = $row['mob_id'];
$mob = $row['mob'];
$body = $row['body'];
$mob_name = $row['mob_name'];
$health = $row['health'];
$level = $row['level'];
// Print out the contents of each row into a table
echo "<tr><td>";
echo "<img src='/testarea/include/mobs/$mob' />";
echo "</td><td>";
echo $mob_name;
echo "</td><td>";
echo $level;
echo "</td><td>";
echo $health;
echo "</td><td>";
echo
"
<a onmouseover='popup($('#hidden-table').html(), 400);' href='somewhere.html'><img src='/testarea/include/mobs/dead/$body' /></a>
";
echo "
<div id='hidden-table' style='display:none;'>
<table border='0' cellpadding='0' cellspacing='0' class='center3'>
<tr>
<td width='14'><img src='images/info_tl.png'></td>
<td style='background: url(images/info_tm.png)' align='center'></td>
<td width='14'><img src='images/info_tr.png'></td>
</tr>
<tr>
<td style='background: url(images/info_ml.png)'><h2>.</h2></td>
<td style='background: url(images/info_mm.png)'>
";
$query2 = mysql_query("SELECT * FROM tbl_drop WHERE mob_name='$mob_name'") or die(mysql_error());;
echo "<table border='0' cellpadding='1' cellspacing='1' width='250' id='2' class='tablesorter'><thead>";
echo "<tr> <th> </th> <th>Item Name</th> <th>Qty</th></thead><tbody>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $query2 )) {
$id = $row['id'];
$item_img = $row['item_img'];
$qty = $row['qty'];
$item_name = $row['item_name'];
// Print out the contents of each row into a table
echo "<tr><td width='50'>";
echo "<img src='/testarea/item/$item_img' />";
echo "</td><td width='150'>";
echo $item_name;
echo "</td><td width='50'>";
echo $qty;
echo "</td></tr>";
}
echo "</tbody></table>";
echo "
</td>
<td style='background: url(images/info_mr.png)'><h2>.</h2></td>
</tr>
<tr>
<td width='14'><img src='images/info_bl.png'></td>
<td style='background: url(images/info_bm.png)' align='center'><h2>.</h2></td>
<td width='14'><img src='images/info_br.png'></td>
</tr>
</table>
</div>"
;
echo "</td><td>";
echo "test";
echo "</td><td>";
echo "test";
echo "</td></tr>";
}
echo "</tbody></table>";
?>
</td>
<td style="background: url(images/box_mr.png)"><h2>.</h2></td>
</tr>
<tr>
<td width='60'><img src="images/box_bl.png"></td>
<td style="background: url(images/box_bm.png)" align="center"><h2>.</h2></td>
<td width='25'><img src="images/box_br.png"></td>
</tr>
</table>
</html>
you have two semi-colons on this line...could be the problem
$query = mysql_query("SELECT * FROM tbl_drop WHERE mob_name='$mob_name'") or die(mysql_error());;