I've got this code that works well now but thought it would be useful to have the Observed Data start from the newest date to the oldest. How can I flip only the Observed Data? Here is the code (Sorry if it doesn't look right on here, still getting use to posting on this site):
<?php
$url = "http://r7j8v4x4.map2.ssl.hwcdn.net/NOD_R.xml";
$xml = simplexml_load_file($url);
?>
<?php foreach ($xml->RESULTSET[0]->ROW as $MSG) :?>
<?php echo '<h4>', $MSG->MSG_TXT; '</h4>'; ?>
<?php endforeach; ?>
<!-- Table Style -->
<style>
table {border: 2px solid #fff;}
table td {height: 15px;}
table td {border: 1px solid #fff; }
table tr {border: 1px solid #fff; }
table td {padding: 3px; }
</style>
<h2>Observed Data</h2>
<table>
<div style="overflow-x:auto;">
<thead>
<tr>
<td><span style="margin:0px; font-weight:bold">Day</span></td>
<td><span style="margin:0px; font-weight:bold">Time(EST)</span></td>
<td><span style="margin:0px; font-weight:bold">Reservoir Elev.(behind dam)*</span</td>
<td><span style="margin:0px; font-weight:bold">Tailwater Elev.(below dam)*</span></td>
<td><span style="margin:0px; font-weight:bold">Avg Hourly Discharge* </span></td>
</tr>
</thead>
<tbody>
<?php foreach ($xml->RESULTSET[1]->ROW as $obs) :?>
<tr>
<td><?php echo $obs->OBS_DAY; ?></td>
<td><?php echo $obs->OBS_HR; ?></td>
<td><?php echo $obs->UPSTREAM_ELEV; ?></td>
<td><?php echo $obs->DOWNSTREAM_ELEV; ?></td>
<td><?php echo $obs->AVG_HOURLY_DISCHARGE; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2>Predicted Data</h2>
<table>
<div style="overflow-x:auto;">
<thead>
<tr>
<td><span style="margin:25px; font-weight:bold">Day</span></td>
<td><span style="margin:5px; font-weight:bold">Average Inflow* </span</td>
<td><span style="margin:5px; font-weight:bold">Midnight Elevation*</span></td>
<td><span style="margin:5px; font-weight:bold">Average Outflow*</span></td>
</tr>
</thead>
<tbody>
<?php foreach ($xml->RESULTSET[2]->ROW as $pred) :?>
<tr>
<td><?php echo $pred->PREDICTED_DAY; ?></td>
<td><?php echo $pred->DAILY_AVG_INFLOW; ?></td>
<td><?php echo $pred->MIDNIGHT_ELEV; ?></td>
<td><?php echo $pred->DAILY_AVG_OUTFLOW; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>`
You can read them into arrays before you output.
foreach ($xml->RESULTSET[1]->ROW as $obs) {
$resultSet1[] = $obs;
}
foreach ($xml->RESULTSET[2]->ROW as $obs) {
$resultSet2[] = $obs;
}
That will make it easier for you to reverse them. Once they're in arrays there are various ways to do it. You can use array_reverse, a for loop with a decrementing index, or something like this:
<?php while ($obs = array_pop($resultSet1)) :?>
<tr>
<td><?php echo $obs->OBS_DAY; ?></td>
<td><?php echo $obs->OBS_HR; ?></td>
<td><?php echo $obs->UPSTREAM_ELEV; ?></td>
<td><?php echo $obs->DOWNSTREAM_ELEV; ?></td>
<td><?php echo $obs->AVG_HOURLY_DISCHARGE; ?></td>
</tr>
<?php endwhile; ?>
In my PHP code is below.
<table width="100%" >
<tr width="100%" class="bgcolor_02">
<th ROWSPAN="2" >SUBJECTS </th>
<th COLSPAN="2" >EXAMS </th>
<th COLSPAN="2" >PROJECTS </th>
</tr>
<tr class="bgcolor_02">
<th id="1E"> 1.EXAM</th>
<th id="2E"> 2.EXAM</th>
<th id="1P"> 1.PROJECT</th>
<th id="2P"> 2.PROJECT</th>
</tr>
<?php
$myexamresults = $db-> getrows (" SELECT * FROM `es_exam_result` WHERE `es_studentid` = '".$_SESSION['eschools']['user_id']."' ORDER BY `es_examorder` ASC ");
$pre_subjects=subjectnameByClass($es_subjectshortname);
foreach ($pre_subjects as $ndsdersliste ) {
$subjeid=$ndsdersliste['es_subjectid']; ?>
<tr > <td ><?php echo $ndsdersliste['es_subjectname']; ?></td>
<?php
foreach ($myexamresults as $ndsmyexam) {
$puan="";
if( $ndsdersliste['es_subjectname'] == $ndsmyexam['es_subjectname'] ) {
$examname = $ndsmyexam['es_examname'];
$puan = $ndsmyexam['es_puan'];
if ($examname =="1.Exam"){ ?> <td headers="1E" ><?php {echo $puan ;} ?> </td> <?php }
if ($examname =="2.Exam"){ ?> <td headers="2E" ><?php {echo $puan ;} ?> </td> <?php }
if ($examname =="1.Project"){ ?> <td headers="1P" ><?php {echo $puan ;} ?> </td> <?php }
if ($examname =="2.Project"){ ?> <td headers="2P" ><?php {echo $puan ;} ?> </td> <?php }
} } ?>
</tr>
<?php } ?>
</table>
I can get exam results from database. But I can not insert correct data under headers. If a student have just "1.Project" result, It is showing under "1.Exam". How to insert under correct title. Thanks..
You have to create empty <td> if there is no result to have the same number of <td> for each <tr>:
<tr > <td ><?php echo $ndsdersliste['es_subjectname']; ?></td>
<?php
$td = [];
foreach ($myexamresults as $ndsmyexam) {
$puan="";
if( $ndsdersliste['es_subjectname'] == $ndsmyexam['es_subjectname'] )
{
$examname = $ndsmyexam['es_examname'];
$puan = $ndsmyexam['es_puan'];
if ($examname =="1.Exam") { $td['1E'] = $puan ; }
if ($examname =="2.Exam") { $td['2E'] = $puan ; }
if ($examname =="1.Project") { $td['1P'] = $puan ; }
if ($examname =="2.Project") { $td['2P'] = $puan ; }
}
}
if (isset($td['1E'])) echo '<td headers="1E">'.$td['1E'] .'</td>' ; else echo '<td headers="1E"></td>' ;
if (isset($td['2E'])) echo '<td headers="2E">'.$td['2E'] .'</td>' ; else echo '<td headers="2E"></td>' ;
if (isset($td['1P'])) echo '<td headers="1P">'.$td['1P'] .'</td>' ; else echo '<td headers="1P"></td>' ;
if (isset($td['2P'])) echo '<td headers="2P">'.$td['2P'] .'</td>' ; else echo '<td headers="2P"></td>' ;
?>
</tr>
I have developed shopping cart in PHP but while inserting cart data into the database I got an error of undefined index. Can anybody please tell me how do I solve it? I have called all the three values using POST method and these all are also present in the database still i am getting this error.Why?
Code:
reviewcart.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "midata";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$code=$_POST['code'];
$quantity=$_POST['quantity'];
$sql = "INSERT INTO order_final (name, code, quantity)
VALUES ('$name', '$code', '$quantity')";
if ($conn->query($sql) === TRUE) {
}
else{
}
}
else{ echo 'query doesnt execute';
}
?>
<div class="container">
<?php
session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_GET["action"])) {
switch($_GET["action"]) {
case "remove":
if(!empty($_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($_GET["code"] == $k)
unset($_SESSION["cart_item"][$k]);
if(empty($_SESSION["cart_item"]))
unset($_SESSION["cart_item"]);
}
}
break;
case "empty":
unset($_SESSION["cart_item"]);
break;
}
}
?>
<div class="c-layout-sidebar-content ">
<!-- BEGIN: PAGE CONTENT -->
<div class="c-content-title-1 c-margin-t-30">
<h3 class="c-font-uppercase c-font-bold c-center ">Place Order</h3>
<div class="c-content-panel">
<div class="c-body">
<div class="row">
<div class="col-md-12">
<table class="table table-condensed">
<div id="shopping-cart">
<div class="txt-heading">Shopping Cart <a id="btnEmpty" href="reviewcart.php?action=empty">Empty Cart</a></div>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?>
<table class="col-md-12" cellpadding="10" cellspacing="1" >
<tbody class="col-md-12">
<tr>
<form action="" method="post">
<th class="col-md-3" style="text-align:center;"><strong>Name</strong></th>
<th class="col-md-3" style="text-align:center;"><strong>Code</strong></th>
<th class="col-md-3" style="text-align:center;"><strong>Quantity</strong></th>
<th class="col-md-3" style="text-align:center;"><strong>Price</strong></th>
<th class="col-md-3" style="text-align:center;"><strong>Action</strong></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><strong><?php $name=$_POST['name'] ; echo $item["name"]; ?></strong></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><?php $code=$_POST['code'] ; echo $item["code"]; ?></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><?php $quantity=$_POST['quantity'] ; echo $item["quantity"]; ?></td>
<!-- <td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><?php $price=$_POST['price'] ; echo $price ?></td> -->
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">Remove Item</td>
</tr>
<!-- <?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
-->
<tr>
<td colspan="5" align=right><input type="submit" name="submit" value="submit" /></td>
</tr></form>
</tbody>
</table>
<?php
}
?>
</div>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
If we want to post any data via form mean we must want to use input tag then only we can accept it values on global arrays like $_POST, $_GET, $_FILES.
<tr>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<strong><?php echo $item["name"]; ?></strong>
<input type="hidden" name="name" value="<?php echo $item['name']?>">
</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<?php echo $item["code"]; ?>
<input type="hidden" name="code" value="<?php echo $item['code']?>">
</td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<?php echo $item["quantity"]; ?>
<input type="hidden" name="quantity" value="<?php echo $item['quantity']?>">
</td>
<!-- <td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<?php $price=$_POST['price'] ; echo $price ?>
</td> -->
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">
<a href="reviewcart.php?action=remove&code=<?php echo $item["code"]; ?>" class="btnRemoveAction">
Remove Item
</a>
</td>
</tr>
Hello this is the code in my php, i dont get error but the items in the database doesn't show and only the else tag is execute.
<?php
$sql = $bdd->prepare('SELECT * FROM bgk9z_items');
if ($sql->fetchColumn() > 0) { //
while ($result = $sql->fetch(PDO::FETCH_ASSOC)){
?>
<tr>
<th id="checkbox"><input type="checkbox" name="toggle" /></th>
<td id="titre"><? echo $result['title']; ?>
<div class="opt"><span class="up">Modifier</span> <span class="del">Supprimer</span> <span class="sho">Afficher</span></div>
</td>
<td id="extrait"><? $string = $result['introtext']; $long = (strlen($string) > 13) ? substr($string,0,280).'...' : $string; echo $long;?></td>
<td id="cat"><? include_once(dirname(__DIR__) . '/controlers/show-cat-name.php'); ?></td>
<td id="etat"><? $rep = $result['published']; if ($rep == 1) { echo "Oui";} else{echo "Non";} ?></td>
<td id="image"><? echo "Image"; ?></td>
<td id="ident"><? echo $result['id']; ?></td>
</tr>
<?
}
}
else { ?>
<tr><td colspan="7" style="text-align: center; color: rgb(192, 0, 0); font-size: 23px; font-weight: bold;">NO ITEM TO SHOW</td></tr>
<?php }
?
I am new in php. I want to create a table using loop. I have a select query and i want that the result of that query is display in table. i have multiple columns in my table.
<?php
$con=mysqli_connect("localhost","root","","pacra1");
// $id2 = $_GET['id'];
$sql = "SELECT pc.id, l.id, l.to_name, l.to_designation, l.company, l.address, l.confidential, l.date, l.rating_type_title, l.opinion_type, l.dear_sir, l.company_id, l.first_opinion_name, l.first_opinion_rating_type, l.first_opinion_action, l.first_opinion_outlook, l.first_opinion_long_term, l.first_opinion_p_long_term, l.first_opinion_short_term, l.first_opinion_p_short_term, l.second_opinion_name, l.second_opinion_rating_type, l.second_opinion_action, l.second_opinion_outlook, l.second_opinion_long_term, l.second_opinion_p_long_term, l.second_opinion_short_term, l.second_opinion_p_short_term, l.third_opinion_name, l.third_opinion_rating_type, l.third_opinion_action, l.third_opinion_outlook, l.third_opinion_long_term, l.third_opinion_p_long_term, l.third_opinion_short_term, l.third_opinion_p_short_term, l.forth_opinion_name, l.forth_opinion_rating_type, l.forth_opinion_action, l.forth_opinion_outlook, l.forth_opinion_long_term, l.forth_opinion_p_long_term, l.forth_opinion_short_term, l.forth_opinion_p_short_term, l.y_truly, l.s_name, l.uh1, l.uh2, l.uh1_designation, l.uh2_designation, l.s_designation, l.chk, l.chk1
FROM letter l
LEFT JOIN pacra_clients pc
ON l.company_id = pc.id
ORDER BY l.id DESC
LIMIT 1";
$result=mysqli_query($con,$sql);
$row= (mysqli_fetch_array($result,MYSQLI_ASSOC));
$id= $row['id'];
$to_name= $row['to_name'];
$to_designation= $row['to_designation'];
$company= $row['company'];
$address= $row['address'];
$confidential = $row['confidential'];
$date = $row['date'];
$phpdate = strtotime( $date );
$date = date( 'M d, Y', $phpdate );
$rating_type_title= $row['rating_type_title'];
$opinion_type= $row['opinion_type'];
$dear_sir= $row['dear_sir'];
$company_id= $row['company_id'];
$first_opinion_name= $row['first_opinion_name'];
$first_opinion_rating_type= $row['first_opinion_rating_type'];
$first_opinion_action= $row['first_opinion_action'];
$first_opinion_outlook= $row['first_opinion_outlook'];
$first_opinion_long_term= $row['first_opinion_long_term'];
$first_opinion_p_long_term= $row['first_opinion_p_long_term'];
$first_opinion_short_term= $row['first_opinion_short_term'];
$first_opinion_p_short_term= $row['first_opinion_p_short_term'];
$second_opinion_name= $row['second_opinion_name'];
$second_opinion_rating_type= $row['second_opinion_rating_type'];
$second_opinion_action= $row['second_opinion_action'];
$second_opinion_outlook= $row['second_opinion_outlook'];
$second_opinion_long_term= $row['second_opinion_long_term'];
$second_opinion_p_long_term= $row['second_opinion_p_long_term'];
$second_opinion_short_term= $row['second_opinion_short_term'];
$second_opinion_p_short_term= $row['second_opinion_p_short_term'];
$third_opinion_name= $row['third_opinion_name'];
$third_opinion_rating_type= $row['third_opinion_rating_type'];
$third_opinion_action= $row['third_opinion_action'];
$third_opinion_outlook= $row['third_opinion_outlook'];
$third_opinion_long_term= $row['third_opinion_long_term'];
$third_opinion_p_long_term= $row['third_opinion_p_long_term'];
$third_opinion_short_term= $row['third_opinion_short_term'];
$third_opinion_p_short_term= $row['third_opinion_p_short_term'];
$forth_opinion_name= $row['forth_opinion_name'];
$forth_opinion_rating_type= $row['forth_opinion_rating_type'];
$forth_opinion_action= $row['forth_opinion_action'];
$forth_opinion_outlook= $row['forth_opinion_outlook'];
$forth_opinion_long_term= $row['forth_opinion_long_term'];
$forth_opinion_p_long_term= $row['forth_opinion_p_long_term'];
$forth_opinion_short_term= $row['forth_opinion_short_term'];
$forth_opinion_p_short_term= $row['forth_opinion_p_short_term'];
$y_truly= $row['y_truly'];
$s_name= $row['s_name'];
$s_designation= $row['s_designation'];
$chk = $row['chk'];
$chk1 = $row['chk1'];
$uh1 = $row['uh1'];
$uh2 = $row['uh2'];
$uh1_designation = $row['uh1_designation'];
$uh2_designation = $row['uh2_designation'];
if ($s_designation == "coo"){
$s_designation ="Chief Operating Officer";
}
elseif ($s_designation == "uh") {
$s_designation ="Unit Head";
}
?>
And HTML
<div style=" font-family: 'Times New Roman', Times, serif;">
<div style=" margin:auto; width:60px; height:auto; align: middle">
<img src="image/pacra_logo.png" alt="logo">
</div>
<div style="margin:auto; width:auto; text-align:center; font-family:'Times New Roman', Times, serif; font-variant: small-caps; font-size:20px; font-weight:bold">
The Pakistan Credit Rating Agency Limited
<hr>
</div>
</div>
<div style="margin-top: 7px; width: auto; font-family:'Times New Roman', Times, serif; float:left">NL FY <?php echo date('y') ?> - <?php echo $id ?>
</div>
<div style="clear: both;"></div>
<div style=" margin-top:20px; width:250px; float:left; font-family:'Times New Roman', Times, serif; text-align:left; font-size:14px; l">
<b> <?php echo $to_name?> </b> <br /><?php echo $to_designation?> </br> <?php echo $company?> </br> <?php echo $address ?>
</div>
<div style=" margin-top:20px; margin-left:300px; width:auto; float:left; font-family:'Times New Roman', Times, serif; font-size:14px;">
<b> <u> <?php echo $confidential ?> </u> </b> </br> <?php echo $date ?>
</div>
<div style="clear: both;"></div>
<div style="margin-top:20px; margin-right:auto; width:auto; font-family:'Times New Roman', Times, serif; text-align:center; font-variant:small-caps; font-size:18px; font-weight:bold; color:#009"> <?php echo $company?> <br /> Ratings - <?php
if ($opinion_type == "up") {
echo "Update";}
elseif ($opinion_type =="in") {
echo "Initial";}
?>
</div>
<div style="margin-top:10px; width:auto; float:left; font-family:'Times New Roman', Times, serif">
<?php echo $dear_sir?>
</div>
<div style="clear: both;"></div>
<div style="margin-top:10px; width:auto; float:left; font-family:'Times New Roman', Times, serif; text-align:justify">
<?php
if ($opinion_type == "up") {
echo "This is with the reference to"; echo ' '; echo "ratings of"; echo ' '; echo $company ;
echo ". PACRA has updated its opinions, following are the respective details.";
} elseif ($opinion_type == "in") {
echo "This is with the refrence to "; echo $rating_type_title; echo " ratings of "; echo $company ; echo ". PACRA assign its opinions, following are the rspective detail";
}
?>
</div>
<div style="clear: both;"></div>
<div style="margin-top:20px; width:auto; align:middle; font-family:'Times New Roman', Times, serif">
<!--<table width="100%">
<tr> <td colspan="03"> <b> Name:</b> </td>
<td width="429"><b> <?php //echo $company?></b> </td>
</tr>
</table> -->
</div>
<div style="margin-top:40px; width:auto;font-family:'Times New Roman', Times, serif; text-align:left; font-size:12px; text-align:center">
<table width="657">
<tr>
<td width="225"> <strong>Opinion</strong></td>
<td width="62"> <strong>Action</strong></td>
<td colspan="4"><strong>Ratings</strong></td>
<td width="54"><strong>Outlook</strong></td>
<td width="67"><strong>Rating Type</strong></td>
</tr>
<tr>
<td width="225"> </td>
<td width="62"> </td>
<td colspan="2"><b>Long Term</b></td>
<td colspan="2"><b>Short Term</b></td>
<td width="54"> </td>
<td width="67"> </td>
</tr>
<tr>
<td width="225"> </td>
<td width="62"> </td>
<td width="52"><b>Current</b></td>
<td width="45"><b>Previous</b></td>
<td width="49"><b>Current</b></td>
<td width="51"><b>Previous</b></td>
<td width="54"> </td>
<td width="67"> </td>
</tr>
<tr>
<td><?php echo $first_opinion_name?></td>
<td><?php echo $first_opinion_action ?></td>
<td><?php echo $first_opinion_long_term ?></td>
<td><?php echo $first_opinion_p_long_term?></td>
<td><?php echo $first_opinion_short_term ?></td>
<td><?php echo $first_opinion_p_short_term ?></td>
<td><?php echo $first_opinion_outlook ?></td>
<td><?php echo $first_opinion_rating_type ?></td>
</tr>
<tr>
<td><?php echo $second_opinion_name?></td>
<td><?php echo $second_opinion_action ?></td>
<td><?php echo $second_opinion_long_term ?></td>
<td><?php echo $second_opinion_p_long_term?></td>
<td><?php echo $second_opinion_short_term ?></td>
<td><?php echo $second_opinion_p_short_term ?></td>
<td><?php echo $second_opinion_outlook ?></td>
<td><?php echo $second_opinion_rating_type ?></td>
</tr>
<tr>
<td><?php echo $third_opinion_name?></td>
<td><?php echo $third_opinion_action ?></td>
<td><?php echo $third_opinion_long_term ?></td>
<td><?php echo $third_opinion_p_long_term?></td>
<td><?php echo $third_opinion_short_term ?></td>
<td><?php echo $third_opinion_p_short_term ?></td>
<td><?php echo $third_opinion_outlook ?></td>
<td><?php echo $third_opinion_rating_type ?></td>
</tr>
<tr>
<td><?php echo $forth_opinion_name?></td>
<td><?php echo $forth_opinion_action ?></td>
<td><?php echo $forth_opinion_long_term ?></td>
<td><?php echo $forth_opinion_p_long_term?></td>
<td><?php echo $forth_opinion_short_term ?></td>
<td><?php echo $forth_opinion_p_short_term ?></td>
<td><?php echo $forth_opinion_outlook ?></td>
<td><?php echo $forth_opinion_rating_type ?></td>
</tr>
</table>
</div>
<div style="clear: both;"></div>
<div style="margin-top:50px; width:auto; text-align:left; font-family:'Times New Roman', Times, serif">
<?php echo $y_truly ?>
</div>
<div style="clear: both;"></div>
<div style="margin-top:70px; text-align:left; font-family:'Times New Roman', Times, serif; float:left">
<?php
if ($s_name == "shahzad"){
echo '<b>'; echo "(Muhammad Shahzad Saleem)"; echo '</b>' ;
echo '<br/>';
echo $s_designation;
}
?>
</div>
<div style="margin-top:50px; text-align:left; font-family:'Times New Roman', Times, serif; float:left">
<?php
if ($s_name == "hanif") {
echo '<b>'; echo "(Muhammad Jhangeer Hanif)"; echo '</b>' ;
echo '<br/>';
echo $s_designation;
}
elseif ($s_name == "rana") {
echo '<b>'; echo "(Rana Muhammad Nadeem)"; echo '</b>' ;
echo '<br/>';
echo $s_designation;
}
?>
</div>
<div style="margin-top:50px; text-align:left; font-family:'Times New Roman', Times, serif; float:left; margin-left:220px">
<?php
if ($s_name == "rana") {
echo '<b>'; echo "(Muhammad Jhangeer Hanif)"; echo '</b>' ;
echo '<br/>';
echo $s_designation;
}
elseif ($s_name == "hanif") {
echo '<b>'; echo "(Rana Muhammad Nadeem)"; echo '</b>' ;
echo '<br/>';
echo $s_designation;
}
?>
</div>
<div style="margin-top:50px; width:auto; text-align:left; font-family:'Times New Roman', Times, serif; float:left">
<?php if ($s_designation == "coo"){
echo "Chief Operating Officer";
}
elseif ($s_designation == "uh") {
echo "Unit Head";
}
?>
</div>
<div style="margin-top:auto; width:auto; text-align:left; font-family:'Times New Roman', Times, serif; float:left; margin-left:362px">
<?php if ($s_designation == "uh") {
echo "Unit Head";
}
?>
</div>
<div style="clear: both;"></div>
<div style="margin-top: 50px; width:auto; text-align:left; font-family:'Times New Roman', Times, serif">
<?php if ($chk == "p_release"){
echo "Encl: 1) Press Release";
}
echo '</br>';
if ($chk1 == "r_report"){
echo " "; echo "Rating Report";
}
?>
</div>
Why i want this?
Coz i display my record in table through my db. some times there is record only for two rows of table. I statically create four rows of table. If there is two row record then my reaming two rows will be shown empty. I want to create my table according to data in my db.
I have no idea how i can do it?
Can you gys please help me?
use foreach loop after mysql fetch query.
<?php
foreach($row as $rows)
{
$id= $rows['id'];
$to_name= $rows['to_name'];
$to_designation= $rows['to_designation'];
$company= $rows['company'];
$address= $rows['address'];
$confidential = $rows['confidential'];
$date = $rows['date'];
$phpdate = strtotime( $date );
$date = date( 'M d, Y', $phpdate );
$rating_type_title= $rows['rating_type_title'];
$opinion_type= $rows['opinion_type'];
$dear_sir= $rows['dear_sir'];
$company_id= $rows['company_id'];
$first_opinion_name= $rows['first_opinion_name'];
$first_opinion_rating_type= $rows['first_opinion_rating_type'];
$first_opinion_action= $rows['first_opinion_action'];
$first_opinion_outlook= $rows['first_opinion_outlook'];
$first_opinion_long_term= $rows['first_opinion_long_term'];
$first_opinion_p_long_term= $rows['first_opinion_p_long_term'];
$first_opinion_short_term= $rows['first_opinion_short_term'];
$first_opinion_p_short_term= $row['first_opinion_p_short_term'];
}
?>