I am on the way to create a webform for education related activity. My mysql table looks like this
+----+--------+---------+-----------+---------+-----------------------------
| id |schlname| trname | pay |oa |gross|trname2|pay2|oa2|gross2| -----etc
+----+--------+---------+-----------+---------+-----------------------------
| 1 |Greatedn| Bredier| 1000 | 25|1025|Pastiur |1000| 25|1025 |
2 |Meritedn| Paskin | 1000 | 25|1025|Blazer |1000| 25|1025 |
+----+--------+---------+-----------+---------+----------------------------
I need to take report using php query using echo statement. My expected report should be like this
+----+--------+---------+-----------+-------
| id |schlname| trname | pay | oa |gross |
+----+--------+---------+-----------+-------
| 1 |Greatedn| Bredier| 1000 | 25 |1025 |
Pastiur |1000 | 25 |1025 |
etc...
etc...
2 |Meritedn| Paskin | 1000 | 25 |1025 |
Blazer |1000 | 25 |1025 |
etc...
etc..
Your valuable ideas are expected to complete my study
This is untested, but I'd go somewhere along these lines, maybe a double for loop if you want to make it look pretty
require "conn.php";
$sql = $dbh->prepare("SELECT * FROM yourtablename WHERE 1");
$sql->execute();
$data_storage = $sql->fetch_all();
for($i = 0; $i < $data_storage->rowCount(); $i++) {
echo $data_storage[$i];
}
Let me know if this answers your question. Not quite sure if this is what you're asking for.
let me know if something fails ;)
<?php
$con=mysqli_connect("#","#","#","#");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
<div id="container">
<br><br>
<section class="column1" style="font-weight:bold;">Reference</section>
<section class="column1" style="font-weight:bold;">Language Combination</section>
<section class="column1" style="font-weight:bold;">Customer Delivery Date</section>
<section class="column1" style="font-weight:bold;">Project Status</section>
<br><br>
$result1 = mysqli_query($con,"SELECT * FROM `table` WHERE schlname="Greatedn" ");
while($row = mysqli_fetch_array($result1))
{
?> <br><br> <section class="column2"> <?php echo $row['id']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['schlname']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['trname']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['pay']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['oa']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['gross']; ?> </section> <?php
?><section class="clearboth"></section><br><br><?php
}
$result2 = mysqli_query($con,"SELECT * FROM `table` WHERE schlname="Meritedn" ");
while($row = mysqli_fetch_array($result2))
{
?> <br><br> <section class="column2"> <?php echo $row['id']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['schlname']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['trname']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['pay']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['oa']; ?> </section> <?php
?> <br><br> <section class="column2"> <?php echo $row['gross']; ?> </section> <?php
?><section class="clearboth"></section><br><br><?php
}
mysqli_close($con);
?>
</div>
CSS
.column 1 {
float: left;
width: 15%;
overflow: hidden;
}
.container {
//Some cool stuff here
}
.clearboth {
clear: both;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.