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)){
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>
";
}
}
Good Day, I want to display the value in my DB in one row. But what is happening now, it is being displayed horizontally
Image Sample
<table class="table table-bordered">
<thead style="font-size:20px;text-align:center;"class="thead-dark">
<tr>
<th class="tblHeader">MODEL</th>
<th class="tblHeader">PERIOD 1</th>
<th class="tblHeader">PERIOD 2</th>
<th class="tblHeader">PERIOD 3</th>
<th class="tblHeader">PERIOD 4</th>
<th class="tblHeader">PERIOD 5</th>
<th class="tblHeader">PERIOD 6</th>
<th class="tblHeader">PERIOD 7</th>
<th class="tblHeader">PERIOD 8</th>
<th class="tblHeader">PERIOD 9</th>
<th class="tblHeader">PERIOD 10</th>
<th class="tblHeader">PERIOD 11</th>
<th class="tblHeader">PERIOD 12</th>
</tr>
</thead>
<?php
$connect = mysqli_connect("localhost", "root", "", "hh_bpm");
$query = "SELECT *
FROM bpm_periods_instance
WHERE Category_Name=1
";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{ ?>
<tbody style="font-size:20px; text-align:center;">
<tr>
<td><?php echo $row["Text_Value"];?></td>
</tr>
<?php } mysqli_close($connect);?>
</tbody>
</table>
I want to display the string value in line with Period 1 - 12`
I'm still trying to learn.
First of all, move your while loop just before the <tr>, for you want to have just one table body. Then it's better to have the same number of <th>s and <td>s. I see you have 12 <th>s, so make 12 <td>s in each <tr> (leave them empty if you want, but include them)
The tags is a row containing headings for your table. For your to Match your column names you must have equal number of as th in your table.
<tr>
<th>heading1</th>
<th>heading2</th>
<th>heading3</th>
</tr>
You can now iterate this for your rows.
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
</tr>
You are showing just a singe TD for each row.
What you are missing is a row loop:
while($row = mysqli_fetch_array($result))
{ ?>
<tbody style="font-size:20px; text-align:center;">
<tr>
<?php
foreach($row as $k=>$v)
echo "<td>$v</td>";
?>
</tr>
<?php } mysqli_close($connect);?>
</tbody>
</table>
Alternatively, you should output TDs for all columns manually:
<tr>
<td><?php echo $row["Column1"];?></td>
<td><?php echo $row["Column2"];?></td>
<td><?php echo $row["Column3"];?></td>
<td><?php echo $row["Column4"];?></td>
<td><?php echo $row["Column5"];?></td>
<td><?php echo $row["Column6"];?></td>
...
</tr>
You need a crosstab query to achieve the results that you want. Since there is very little information I'll just give and outline
SELECT info,
sum( if(MONTH(dt)=1,1,0) as Period_1,
sum( if(MONTH(dt)=2,1,0) as Period_2,
//--- repeat for all 12 months
Your query will return 13 columns (info and Period_1 to Period_12). You'll need to adjust the html to cater for this output.
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>
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>
?>
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");