I'm working with displaying an output when I count the value of the second query is greater than or equal to 2 , using the first query where second query schedule number is equal to the first query schedule number.
The line that I got an error:
if ($x>=2) {.'<button onclick="CreateRevision('.$row['id'].')" type="button" class="btn btn-primary"><span class="fa fa-copy"></span></button>'.} else{}.'.
I just got this message syntax error, unexpected'.'
My whole code is this:
<?php
//open connection to mysql db
include("db_connection.php");
$data = '
<table id="tb_jobsched" class="display nowrap table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="3%">#</th>
<th width="10%">Schedule Number</th>
<th width="20%">Item Name</th>
<th width="10%">Output</th>
<th width="10%">Date Created</th>
<th width="10%">Expected Date</th>
<th width="10%">Prepared By</th>
<th width="7%">Status</th>
<th width="7%"></th>
</tr>
</thead>
<tfoot>
<tr>
<th width="3%">#</th>
<th width="10%">Schedule Number</th>
<th width="20%">Item Name</th>
<th width="10%">Output</th>
<th width="10%">Date Created</th>
<th width="10%">Expected Date</th>
<th width="10%">Prepared By</th>
<th width="7%">Status</th>
<th width="7%"></th>
</tr>
</tfoot>';
$query = "SELECT * FROM prepressjobs WHERE pj_deleted = 0 ORDER BY pj_datecreated DESC";
if (!$result = mysqli_query($db,$query)) {
exit(mysqli_error());
}
// if query results contains rows then featch those rows
if(mysqli_num_rows($result) > 0)
{
$number = 1;
while($row = mysqli_fetch_assoc($result))
{
$data .= '<tr>
<td>'.$number.'</td>
<td>'.$row['pj_schednum'].'</td>
<td>'.$row['pj_itemname'].'</td>
<td>'.$row['pj_output'].'</td>
<td>'.$row['pj_datecreated'].'</td>
<td>'.$row['pj_expectedfinished'].'</td>
<td>'.$row['pj_preparedby'].'</td>
<td>'.$row['pj_status'].'</td>
<td>
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
<button onclick="GetJobDetails('.$row['id'].')" type="button" class="btn btn-primary"><span class="fa fa-gear"></span></button>
'.
$querya = "SELECT COUNT(rm_schednum) AS jobrevision FROM jobrevisions WHERE rm_schednum ='{$row['pj_schednum']}'";
$resulta= mysqli_query($db, $querya);
$rowa = mysqli_fetch_assoc($resulta);
$x=$rowa['jobrevision'];
if ($x>=2) {.'<button onclick="CreateRevision('.$row['id'].')" type="button" class="btn btn-primary"><span class="fa fa-copy"></span></button>'.} else{}.'
</div>
</td>
</tr>';
$number++;
}
}
else
{
// records now found
$data .= '<tr><td colspan="8">Records not found!</td></tr>';
}
$data .= '</table>';
echo $data;
?>
What is the following solution about this?
<?php
<?php
//open connection to mysql db
include("db_connection.php");
$data = '
<table id="tb_jobsched" class="display nowrap table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="3%">#</th>
<th width="10%">Schedule Number</th>
<th width="20%">Item Name</th>
<th width="10%">Output</th>
<th width="10%">Date Created</th>
<th width="10%">Expected Date</th>
<th width="10%">Prepared By</th>
<th width="7%">Status</th>
<th width="7%"></th>
</tr>
</thead>
<tfoot>
<tr>
<th width="3%">#</th>
<th width="10%">Schedule Number</th>
<th width="20%">Item Name</th>
<th width="10%">Output</th>
<th width="10%">Date Created</th>
<th width="10%">Expected Date</th>
<th width="10%">Prepared By</th>
<th width="7%">Status</th>
<th width="7%"></th>
</tr>
</tfoot>';
$query = "SELECT * FROM prepressjobs WHERE pj_deleted = 0 ORDER BY pj_datecreated DESC";
if (!$result = mysqli_query($db,$query)) {
exit(mysqli_error());
}
// if query results contains rows then featch those rows
if(mysqli_num_rows($result) > 0)
{
$number = 1;
while($row = mysqli_fetch_assoc($result))
{
$data .= "<tr>
<td>{$number}</td>
<td>{$row['pj_schednum']}</td>
<td>{$row['pj_itemname']}</td>
<td>{$row['pj_output']}</td>
<td>{$row['pj_datecreated']}</td>
<td>{$row['pj_expectedfinished']}</td>
<td>{$row['pj_preparedby']}</td>
<td>{$row['pj_status']}</td>
<td>
<div class='btn-group' role='group' aria-label='Button group with nested dropdown'>
<button onclick='GetJobDetails({$row['id']})' type='button' class='btn btn-primary'><span class='fa fa-gear'></span></button>
";
$querya = "SELECT COUNT(rm_schednum) AS jobrevision FROM jobrevisions WHERE rm_schednum ='{$row['pj_schednum']}'";
$resulta= mysqli_query($db, $querya);
$rowa = mysqli_fetch_assoc($resulta);
$x = $rowa['jobrevision'];
if ($x>=2) {
$data .= "<button onclick='CreateRevision({$row['id']})' type='button' class='btn btn-primary'><span class='fa fa-copy'></span></button>";
} else{}
$data .= "</div>
</td>
</tr>";
$number++;
}
}
else
{
// records now found
$data .= "<tr><td colspan='8'>Records not found!</td></tr>";
}
$data .= "</table>";
echo $data;
?>
Related
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>
";
}
}
I have an HTML table that fills its data from a table in the database, there's an approve button for the admin to approve the visit and change its status to APPROVED, I need to know how I can be able to select element holding the ID, so I can query on the visits and edit its 'STATUS' attribute
HTML table
Here's the code inserting the table:
<table class="table table-bordered table-striped">
<thead>
<tr>
<th scope="col">Request Num</th>
<th scope="col">Visitor Name</th>
<th scope="col">Car Number</th>
<th scope="col">Visit Date</th>
<th scope="col">Status</th>
<th scope="col">Approve</th>
</tr>
</thead>
<tbody>
<?php
if ($_SESSION['sess_flag'] == 1) {
$getVisits = $connection->prepare("SELECT * FROM Visit");
$getVisits->execute();
$visits = $getVisits->fetchAll();
foreach ($visits as $visit) {
echo " <tr>
<th scope='row' class='id'>". $visit['VISIT_ID'] ."</th>
<td>". $visit['VISITOR_NAME'] ."</td>
<td>". $visit['CAR_PLATE_NUMBER'] ."</td>
<td>". $visit['VISIT_DATE'] ."</td>
<td>". $visit['STATUS'] ."</td>
<td>
<div class='icon-container'>
<i class='far fa-check-square icon'></i>
</div>
</td>
</tr>";
}
}
?>
</tbody>
</table>
You could add a link like this that will send the VISIT_ID as an query parameter "id" to "page.php":
<div class='icon-container'>
<i class='far fa-check-square icon'></i>
</div>
On "page.php" check
if( ! empty($_GET["id"]) {
$id = $_GET["id"];
// Update database...
}
when i use this method, the heading of table is horizontal, not the vertical heading.
$link= mysqli_connect($host, $user, $pass, $db);
if (isset($_GET['eid']))
{
$eid=$_GET['eid'];
}
$output = '';
$count=0;
$sql = "SELECT * FROM event_record where eventID='{$eid}' ";
$result = mysqli_query($link, $sql);
while($row = mysqli_fetch_array($result))
{
$count++;
$output .= "<tr>
<td>$count</td>
<td>{$row['studentID']}</td>
<td>{$row['studentName']}</td>
<td>{$row['contact']}</td>
<td>{$row['program']}</td>
<td>{$row['booking_date']}</td>
<td>{$row['booking_type']}</td>
</tr>
";
}
return $output;
i want the result of the pdf is , the table heading is at the vertical and at the left side, not horizontal.
<table class="table table-bordered">
<tr>
<th width="3%">No.</th>
<th width="10%">Student ID</th>
<th width="10%">Student Name</th>
<th width="10%">Contact</th>
<th width="5%">Program</th>
<th width="8%">Booking Date</th>
<th width="10%">Booking Type</th>
</tr>
<?php
echo fetch_data();
?>
</table>
Below code is merge the value and the table heading
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th width="5%">No.</th>
<th width="15%">Student ID</th>
<th width="20%">Student Name</th>
<th width="15%">Contact</th>
<th width="10%">Program</th>
<th width="15%">Booking Date</th>
<th width="15%">Booking Type</th>
</tr>
';
$content .= fetch_data();
$content .= '</table>';
$obj_pdf->writeHTML($content);
$obj_pdf->Output('file.pdf', 'I');
I need a result like this,
I have problem for show array data from Oracle Database to table HTML.
This is the query :
$sql ="SELECT A.AC,A.CREATED_BY,A.SCHEDULE_COMPLETION_DATE FROM WO A, SECURITY_HEADER B WHERE A.AC LIKE 'PK%' AND A.CREATED_BY=B.\"USER\" AND B.ADOPT_USER_PROFILE LIKE 'MAINT%' AND A.STATUS!='CLOSED' AND A.SCHEDULE_COMPLETION_DATE BETWEEN '$tgl_awal' AND '$tgl_akhir' AND (A.SCHEDULE_COMPLETION_DATE-SYSDATE)<0 ";
$sql_statement = OCIParse($connect,$sql);
OCIExecute($sql_statement);
This is table code
<thead>
<tr bgcolor="#CCCCCC">
<th class="text-center">AC</th>
<th class="text-center">CREATED BY</th>
<th class="text-center">USER PROFILE</th>
<th class="text-center">SCHEDULE COMPLETION DATE</th>
</tr>
</thead>
<?php
while ($row = oci_fetch_array($sql_statement,OCI_BOTH)){
//$no++;
?>
<tbody>
<tr>
<th class="text-center"><font size="2"><?php echo $row['AC']; ?></font></th>
<th class="text-center"><font size="2"><?php echo $row['CREATED_BY']; ?></font></th>
<th class="text-center"><font size="2"><?php echo $row['ADOPT_USER_PROFILE']; ?></font></th>
<th><font size="2"><?php echo $row['SCHEDULE_COMPLETION_DATE']; ?></font></th>
</tr>
</tbody>
<?php
}
oci_free_statement($sql_statement);
oci_close($connect);
?>
</table>
This is a notice :
oci_fetch_array() [function.oci-fetch-array]: ORA-01002: fetch out of sequence in C:\xampp\htdocs\graph\pages\work_orderf3.php on line 544
Line 544
while ($row = oci_fetch_array($sql_statement,OCI_BOTH)){
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>
?>