I am taking data from database and put it in html table that html table looks fine but when i press the send button for email send some times the html table is not aligned in email,it looks like below the date is not align in the specific coloumn
also like this
i don't why it showing "!". can any one guide why this happens,thanks
my code:
$text_mail.= "<table style='border:1px solid black;border-collapse:collapse;'>
<tr >
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Country</th>
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Network Name </th>
<th style='border:1px solid black; width:50px; padding:0 0 0 5px'>MCC</th>
<th style='border:1px solid black; width:50px; padding:0 0 0 5px'>MNC</th>
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Old Price (Euro)</th>
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>New Price (Euro)</th>
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Change</th>
<th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Valid From (DD.MM.YYYY) </th>
</tr>";
while($row = mysql_fetch_array($queryRes))
{
if($row['pricefrom']==0){
$pricefrom="NA";
$change="New Network";
}else{
$pricefrom= $row['pricefrom'];
$change= $row['statusto'];
}
if($row['priceto']==0){
$priceto="NA";
$change="Not Covered";
}else{
$priceto= $row['priceto'];
$change= $row['statusto'];
}
$text_mail.= "<tr>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['country'] . "</td>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['networkname'] . "</td>";
$text_mail.= "<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mcc'] . "</td>";
$text_mail.= "<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mnc'] . "</td>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $pricefrom . "</td>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $priceto . "</td>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $change . "</td>";
$text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" .date('d.m.Y', $row['datetime']) . "</td>";
$text_mail.= "</tr>";
}
$text_mail.= "</table> <br><br>";
You should try like this:
$text_mail.= "<tr>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['country'] . "</td>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['networkname'] . "</td>
<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mcc'] . "</td>
<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mnc'] . "</td>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $pricefrom . "</td>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $priceto . "</td>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $change . "</td>
<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" .date('d.m.Y', $row['datetime']) . "</td>
</tr>";
Related
I am just making a railway reservation project to my college therefor I have to get passenger details and make a 2d array and send it to another page to show the summary but I just don't know how to do that.
my code is
<?php
include('connection.php');
session_start();
$train_number = $_GET['train_number'];
$train_name = $_GET['train_name'];
$coachid = $_GET['coachid'];
$date = $_SESSION['date'];
$day = $_SESSION['day'];
$coachtype = $_SESSION['coachtype'];
$useremail = $_SESSION['useremail'];
if($_SERVER['REQUEST_METHOD']='POST')
{
if(!empty($_POST['proceed']))
{
$i = 1;
while($i<7)
{
"What to write here";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Buy Tickets </title>
<link rel="stylesheet" href="css.css">
</head>
<body>
<div class="wrapper">
<div class="header">
<img src="banner.jpg" height="100%" width="100%"/>
</div>
<div class="navbar">
<ul>
<li>Dashboard </li>
<li>Buy Ticket </li>
<li>Cancel ticket</li>
<li>Edit Profile</li>
<li id="last">Logout</li>
</ul>
</div>
<div>
<?php
echo "<h4 align='center'><u>Booking for </u></h4>";
echo "<table align='center'>
<thead>
<tr style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Train Number </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Train name </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Date </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Coach type </th>
</tr>
</thead>";
echo "<tr>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>".$train_number."</td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>".$train_name."</td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>".$date."</td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>".$coachtype."</td>";
echo "</tr>";
echo "</table>";
echo "<h4 align='center'><u>Passenger details </u></h4>";
echo "<table align='center'>
<thead>
<tr style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> No </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Passenger Name </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Age </th>
<th style='border: 1px solid #dddddd;text-align: left; padding: 8px;'> Gender type </th>
</tr>
</thead>";
$iforlist = 1;
while($iforlist<7)
{
echo "<form method='post'>";
echo "<tr>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'>".$iforlist."</td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'><input type='text' name='passenger_name.".$iforlist."' value='' placeholder='Enter name '></td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'><input type='number' name='passenger_age.".$iforlist."' value='' max='100' min='1' placeholder='Enter passenger age '></td>";
echo "<td style='border: 1px solid #dddddd;text-align: left; padding: 8px;'><select name='passenger_gender.".$iforlist."'>
<option value='Male'>Male</option>
<option value='Female'>Female</option>
</select></td></td>";
echo "</tr>";
$iforlist++;
}
echo "</table>";
echo "<div align='center' style='margin-top:10px;'><input type='submit' align='center' name='proceed' value='Proceed' style='width:100px;height:40px;' placeholder='Enter name '></div>";
echo "</form>";
?>
</div>
</div>
</body>
</html>
So, tell me how can i make fetch data if only 2 or 3 field are filled and make a 2d array of it.
if you want any other information i'll give you..
Here is an example of how to use 2D Arrays in PHP
$cars = array
(
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
Now to access the data, you must specify the row and column:
<?php
echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".<br>";
echo $cars[1][0].": In stock: ".$cars[1][1].", sold: ".$cars[1][2].".<br>";
echo $cars[2][0].": In stock: ".$cars[2][1].", sold: ".$cars[2][2].".<br>";
echo $cars[3][0].": In stock: ".$cars[3][1].", sold: ".$cars[3][2].".<br>";
?>
In this case:
array("Volvo",22,18)
That is a single row (0) and it has three columns (Volvo at row=0 column=0, 22 at row=0 colum=1, etc)
I took the example from here: https://www.w3schools.com/php/php_arrays_multi.asp
Let me know if this helps.
I am new to programming, I have managed to create a page which fetches the data from MySQL.
I have used a jQuery plugin to freeze the first column and first row of my table.
The problem I am facing is, when I try to increase the width of a specific column it is not working.
Please help me to understand how do I increase width for specific column. This is my PHP and CSS for your reference.
Thanks.
PHP
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Region Wise</title>
<link href="css/test.css" rel="stylesheet" media="screen" />
<header class="header">
<div class="titulosHeader">
<h2>Region Wise</h2>
</header>
</head>
<main class="main">
<div class="ContenedorTabla">
<?php
$sql = 'SELECT * from rgn_report';
$result = mysqli_query($con,$sql);
echo "<table id='pruebatabla' class='fht-table hoverTable'>
<thead>
<tr>
<th class='celda_encabezado_general' rowspan='3' style='height:100px;'>REGION</th>
<tr>
<th class='celda_encabezado_general' colspan='4'>KA</th>
<th class='space'></th>
<th class='celda_encabezado_general' colspan='4'>MI</th>
<th class='space'></th>
<th class='celda_encabezado_general' colspan='4'>OT</th>
<th class='space'></th>
<th class='celda_encabezado_general' colspan='4'>FA</th>
<th class='space'></th>
<th class='celda_encabezado_general' colspan='4'>HA</th>
</tr>
<tr>
<th class='celda_encabezado_general'>SOH</th>
<th class='celda_encabezado_general'>CY</th>
<th class='celda_encabezado_general'>CT</th>
<th class='celda_encabezado_general'>WC</th>
<th class='space'></th>
<th class='celda_encabezado_general'>SOH</th>
<th class='celda_encabezado_general'>CY</th>
<th class='celda_encabezado_general'>CT</th>
<th class='celda_encabezado_general'>WC</th>
<th class='space'></th>
<th class='celda_encabezado_general'>SOH</th>
<th class='celda_encabezado_general'>CY</th>
<th class='celda_encabezado_general'>CT</th>
<th class='celda_encabezado_general'>WC</th>
<th class='space'></th>
<th class='celda_encabezado_general'>SOH</th>
<th class='celda_encabezado_general'>CY</th>
<th class='celda_encabezado_general'>CT</th>
<th class='celda_encabezado_general'>WC</th>
<th class='space'></th>
<th class='celda_encabezado_general'>SOH</th>
<th class='celda_encabezado_general'>CY</th>
<th class='celda_encabezado_general'>CT</th>
<th class='celda_encabezado_general'>WC</th>
</tr>
</thead>";
echo "<tbody>";
while ($row = mysqli_fetch_array($result))
{
$rowhighlight = array("RGN1","RGN2","Grand Total");
if (in_array($row['rgn'],$rowhighlight)){
echo "<tr>";
echo "<td class='highlight_cell'>" . $row['rgn']."</td>";
echo "<td class='highlight_cell'>" . number_format($row['KA_SOH'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['KA_CY'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['KA_CT'])."</td>";
echo "<td class='highlight_cell'>" . $row['KA_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='highlight_cell'>" . number_format($row['MI_SOH'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['MI_CY'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['MI_CT'])."</td>";
echo "<td class='highlight_cell'>" . $row['MI_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='highlight_cell'>" . number_format($row['OT_SOH'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['OT_CY'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['OT_CT'])."</td>";
echo "<td class='highlight_cell'>" . $row['OT_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='highlight_cell'>" . number_format($row['FA_SOH'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['FA_CY'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['FA_CT'])."</td>";
echo "<td class='highlight_cell'>" . $row['FA_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='highlight_cell'>" . number_format($row['HA_SOH'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['HA_CY'])."</td>";
echo "<td class='highlight_cell'>" . number_format($row['HA_CT'])."</td>";
echo "<td class='highlight_cell'>" . $row['HA_CVR']."</td>";
echo "</tr>";}
else
{
echo "<tr>";
echo "<td class='excel_cell'>" . $row['rgn']."</td>";
echo "<td class='excel_cell'>" . number_format($row['KA_SOH'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['KA_CY'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['KA_CT'])."</td>";
echo "<td class='excel_cell'>" . $row['KA_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='excel_cell'>" . number_format($row['MI_SOH'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['MI_CY'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['MI_CT'])."</td>";
echo "<td class='excel_cell'>" . $row['MI_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='excel_cell'>" . number_format($row['OT_SOH'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['OT_CY'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['OT_CT'])."</td>";
echo "<td class='excel_cell'>" . $row['OT_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='excel_cell'>" . number_format($row['FA_SOH'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['FA_CY'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['FA_CT'])."</td>";
echo "<td class='excel_cell'>" . $row['FA_CVR']."</td>";
echo "<td class='space'></td>";
echo "<td class='excel_cell'>" . number_format($row['HA_SOH'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['HA_CY'])."</td>";
echo "<td class='excel_cell'>" . number_format($row['HA_CT'])."</td>";
echo "<td class='excel_cell'>" . $row['HA_CVR']."</td>";
echo "</tr>";
}
}
echo "</tbody>";
echo "</table>";
mysqli_close($con);
?>
</div>
</main>
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/jquery.CongelarFilaColumna.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#pruebatabla").CongelarFilaColumna({Columnas:1});
});
</script>
</body>
</html>
CSS
*{
margin: 0;
padding: 0;
border:0;
}
.header, .main {
display: inline-block;
height: auto;
width: 100%;
}
.titulosHeader {
height: auto;
}
.ContenedorTabla {
height: 540px;
border: 1px solid green;
overflow: auto;
position: relative;
max-width:auto;
}
.fht-table,
.fht-table thead,
.fht-table tfoot,
.fht-table tbody,
.fht-table tr,
.fht-table th,
.fht-table td
{
margin: 0;
}
.fht-table{
height: auto;
width: auto;
border-collapse: collapse;
border-spacing: 0;
border: 0 none;
table-layout:fixed;
}
.fht-table th,.fht-table td {
overflow: hidden;
table-layout:fixed;
}
.fht-table-wrapper,
.fht-table-wrapper .fht-thead,
.fht-table-wrapper .fht-tfoot,
.fht-table-wrapper .fht-fixed-column .fht-tbody,
.fht-table-wrapper .fht-fixed-body .fht-tbody,
.fht-table-wrapper .fht-tbody {
overflow: hidden;
position: relative;
}
.fht-table-wrapper .fht-fixed-body .fht-tbody,
.fht-table-wrapper .fht-tbody {
overflow: auto;
}
.fht-table-wrapper .fht-table .fht-cell {
overflow: hidden;
height: 1px;
}
.fht-table-wrapper .fht-fixed-column,
.fht-table-wrapper .fht-fixed-body {
top: 0;
left: 0;
position: absolute;
}
.fht-table-wrapper .fht-fixed-column {
z-index: 1;
}
.fht-fixed-body .fht-thead table {
margin-right: 20px;
border: 0 none;
}
.celda_encabezado_general {
background-color: #4BACC6;
border: 1px solid black;
color: #ffffff;
text-align: center;
font-size: 12px;
font-family: Calibri, sans-serif;
white-space: nowrap;
}
._Separador{
background-color: #fff;
height: 12px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 7px;
}
._Separador div{
width: 4px;
}
.celda_normal {
background-color: #fff;
border: 1px solid #ccc;
padding: 2px 4px;
}
.excel_cell{
border: 1px solid black;
color: #222;
text-align: center;
font-size: 11px;
font-weight: normal;
padding: 5px;
empty-cells: show;
font-family: Calibri, sans-serif;
white-space: nowrap;
}
._cell_header{
background-color: #EEE;
}
._cell_Default{
background-color: #FFF;
text-align: left;
}
.excel_cell div{
width: 30px;
height: 20px;
}
.highlight_cell{
border: 2px solid black;
color: #222;
text-align: center;
font-size: 11px;
font-weight: bold;
padding: 5px;
empty-cells: show;
font-family: Calibri, sans-serif;
white-space: nowrap;
}
.hoverTable tr:hover {
background-color: grey;
}
.space{
border: none;
empty-cells: show;
background-color:grey;
width:10px;
}
Working on invoice module which has two different tables master_table and detail_table. Know i want to display master_table's data above the table then in the table structure showing data of detail_table for each three rows header.
My code looks this.
$n = 0;
$htmlpage = 1;
$query = $dbConnection->prepare("SELECT * FROM master WHERE (DocNo BETWEEN ? AND ?) ORDER BY DocNo ASC");
$query->execute(array($fdcu,$tdcu));
while($rows = $query->fetch())
{
$n++;
$noInvs = $rows['No_of_Inv'];
$dno = $rows['DocNo'];
$name = $rows['Customer_Name'];
Step-1: Now i'm pulling client data from another table
$qry = $dbConnection->prepare("SELECT * FROM client WHERE client_name=?");
$qry->execute(array($name));
$row = $qry->fetch();
$add = $row['address'];
$city = $row['city'];
$proj = $rows['Project'];
$projNo = $rows['Project_No'];
$sermnth = $rows['Service_Month'];
$grandtotal = $rows['Total_Amt'];
$rupee = number2word($grandtotal);
$index = 1;
$ratetot = 0;
$subtotal = 0;
$lastPage = ceil($noInvs/3);
$pageCount = 0;
Step-2: Now check the loop iteration
while($index <= $noInvs)
{
$cnt = 1;
$body = "<div class='main-container'><table width='100%' style='padding:0 0 0 0;' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' align='center' style='border:1px solid #000;'>
<strong style='font-size:30px;'>Data</strong>
</td>
</tr>
<tr>
<td valign='top' align='left' style='padding: 0 0px 0 0px;border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;'>
<table width='100%' align='left' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' style='width:50%; padding:5px; font-size:13px; border-right: solid 1px #000000;text-align:left;'><strong>CUSTOMER:</strong> <br /><p style='font-size:12px;'>$name<br />$add, $city</p></td>
<td valign='top' style='width:50%; font-size:13px;'>
<table width='100%' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='border-right: solid 1px #000000;padding:5px;width:40%;font-size:12px;'><br />Invoice No:<br />Invoice Date:</td>
<td align='left' style='padding:5px;font-size:12px;'><br />$ino<br />$invdate</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;'>
<table width=100% cellpadding='0' cellspacing='0' >
<tbody>
<tr style='border-right:solid 1px #000000;border-bottom:solid 1px #000000;'>
<td style='width:5%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>SN.</td>
<td style='width:45%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Description of Services</td>
<td style='width:13%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Per</td>
<td style='width:10%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Quantity</td>
<td style='width:12%;text-align:center; border-right:solid 1px #000000;border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Rate</td>
<td style='width:15%;text-align:center; border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>Amount in Rs.</td>
</tr>";
Step-4: check the loop condition
while(true)
{
Step-5: checking the iteration count
if($cnt>3)
{
$pageCount++;
break;
}
Step-6: Pulling data from details table
$query1 = $dbConnection->prepare("SELECT * FROM details WHERE DocNo=? AND DocNO_Index=?");
$query1->execute(array($dno,$index));
$rowCnt = $query1->rowCount();
while($rows1 = $query1->fetch())
{
$desg = $rows1['Item'];
$des = $rows1['Description'];
$Quantity = $rows1['Quantity'];
$Rate = $rows1['Rate'];
$per = $rows1['Per'];
$gross = $rows1['Gross'];
$SERVICE_TAX = $rows1['SERVICE'];
$SERVICE_TAX = ($SERVICE_TAX==null)? 0.0 : $SERVICE_TAX;
$SB_Tax = $rows1['SB_Tax'];
$SB_Tax = ($SB_Tax==null)? 0.0 : $SB_Tax;
$Krishi_Kalyan_Cess = $rows1['Krishi_Kalyan_Cess'];
$Krishi_Kalyan_Cess = ($Krishi_Kalyan_Cess==null)? 0.0 : $Krishi_Kalyan_Cess;
$ratetot = $ratetot + $Rate;
$subtotal = $subtotal + $gross;
if($cnt == 1 && $index > 1)
{
$body.= "<tr><td style='width:5%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:45%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>Opening Balance</td><td style='width:13%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:10%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:12%;text-align:right;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($ratetot - $Rate, 2)." /-</td><td style='width:15%;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($subtotal-$gross, 2)." /-</td></tr>";
}
$body.= "<tr><td style='width:5%;height:90px;vertical-align:top;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>$index</td><td style='width:45%;height:90px;vertical-align:top; border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($proj!=null)
$body.= "$proj<br/>";
if($desg!=null)
$body.= "$desg<br/>";
if($des!=null)
$body.= "$des<br/>";
if($projNo!=null)
$body.= "$projNo<br/>";
if($sermnth!=null)
$body.= "$sermnth<br/>";
$body.= "</td><td style='width:13%;height:90px;vertical-align:top;text-align:center; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>$per</td><td style='width:10%;height:90px;vertical-align:top; border-right:solid 1px #000000;padding:3px 5px 3px 5px;text-align:center;;font-size:12px;'>$Quantity</td><td style='width:12%;height:90px;vertical-align:top;text-align:right; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($Rate,2)."/-</td><td style='width:15%;height:90px;vertical-align:top; padding:3px 5px 3px 5px; text-align:right;;font-size:12px;'>". number_format($gross,2)."/-</td></tr>";
if($cnt == 3 || $index == $noInvs)
{
$body.= "<tr><td style='width:5%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:45%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($index != $noInvs)
{
$body.= "Closing Balance";
}
$body.= "</td> <td style='width:13%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:10%;border-right:solid 1px #000;padding:3px 5px 3px 5px;font-size:12px;'></td><td style='width:12%;border-right:solid 1px #000;border-top:solid 1px #000;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($ratetot,2)."/-</td><td style='width:15%;border-top:solid 1px #000;text-align:right;padding:3px 5px 3px 5px;font-size:12px;'>". number_format($subtotal,2)."/-</td></tr>";
}
}
$index++;
$cnt++;
}
$body .= "</tbody></table></td></tr>";
$stax = round($subtotal*($SERVICE_TAX/100),2);
$sbc = round($subtotal*($SB_Tax/100),2);
$kkc = round($subtotal*($Krishi_Kalyan_Cess/100),2);
$grandtotal = round(($subtotal+$stax+$sbc+$kkc),2);
$rupee = number2word($grandtotal);
$body .="<tr><td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;;font-size:12px;'><table cellpadding='0' cellspacing='0' width='100%'><tr><td rowspan='2' style='width:50%;height:50px; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount == $lastPage)
{
$body .= "<strong style='font-size:12px;'>Narration : </strong><br/>Amount in Words (Rupees):<br/>";
}
$body .= "<br/>$rupee";
$body .= "</td><td style='width:35%; border-bottom:solid 1px #000000;border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "Sub Total : <br />Service Tax # 14% <br />Swachh Bharat Cess # 0.5% <br />Krishi Kalyan Cess # 0.5% <br />";
}
$body .= "</td><td style='width:15%;text-align:right; border-bottom:solid 1px #000000;padding:3px 5px 3px 5px;;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "". number_format($subtotal,2)."/-<br />".number_format($stax,2)."/-<br />".number_format($sbc,2)."/-<br />".number_format($kkc,2)."/-<br />";
}
$body .= "</td></tr><tr><td style='width:35%; border-right:solid 1px #000000;padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount==$lastPage)
{
$body .= "Total Amount";
}
$body .= "</td><td style='width:15%;text-align:right; padding:3px 5px 3px 5px;font-size:12px;'>";
if($pageCount == $lastPage)
{
$body .= number_format($grandtotal,2)."/-";
}
$body .= "</td></tr></table></td></tr><tr><td valign='top' align='left' style='border-left: solid 1px #000000;border-right: solid 1px #000000;border-bottom: solid 1px #000000;;font-size:12px;'><table width='100%' cellpadding='0' cellspacing='0'>
<tbody>
<tr>
<td style='width:50%; padding:3px 5px 3px 5px;border-right:1px solid #000;font-size:12px;'>
<strong>Thank you</strong>
</td>
<td valign='bottom' align='center' style='width:50%; text-align:center;font-size:12px;'>
<strong>AUTHORISED SIGNATORY</strong>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<p> </p></div>";
$body .= "<html><head><title>$ino</title><style type='text/css'>.main-container{display: block;} #media print{.main-container{display: block;}#page{size:portrait;margin:10px auto;padding:0}.main-container{page-break-after:always!important;}}</style><script language='javascript' type='text/javascript'>function PrintPage() { window.print(); } </script></head><body style='font-size: 12px ! important;'>$body</body></html><!-- onload='window.print()'-->";
echo "$body";
}
}
Issue is loop iteration.
My code output like this
Any suggestions on how to do this or to point me in the right direction would be greatly appreciated.
You're trying to re-use an active database connection. That doesn't work. You need two connections.
Specifically, you're in the process of reading a result set from a query on your connection,
$query = $dbConnection->prepare("some query");
$query->execute(array($fdcu,$tdcu));
while($rows = $query->fetch()) {
...
when you issue another query on the same $dbConnection ...
$qry = $dbConnection->prepare("another query");
$qry->execute(array($name));
You Can't Do Thatâ„¢ while the first query is still active. Open up and use a different connection for the queries issued from inside your loop.
<?php
$con=mysqli_connect("localhost","root","","db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$co_name = mysqli_real_escape_string($con, $_POST['co_name']);
$co_address = mysqli_real_escape_string($con, $_POST['co_address']);
$co_website = mysqli_real_escape_string($con, $_POST['co_website']);
$co_phoneno = mysqli_real_escape_string($con, $_POST['co_phoneno']);
$co_contactperson = mysqli_real_escape_string($con, $_POST['co_contactperson']);
$therapist_id = mysqli_real_escape_string($con, $_POST['therapist_id']);
$result = mysqli_query($con,"SELECT * FROM therapist_office WHERE therapist_id='".$user_id."'");
echo"<table id='miyazaki' style='border-collapse: collapse; border: 1px solid; margin-left:180px; width:1000px; margin-top:30px;'>";
echo"<thead style='border:1px solid; background-color:#ffe3ab;' >";
echo"<tr>";
echo"<th style='border: 1px solid; padding: .65em;' >Office Name</th>";
echo"<th style='border: 1px solid; padding: .65em;' >Address</th>";
echo"<th style='border: 1px solid; padding: .65em;' >Website</th>";
echo"<th style='border: 1px solid; padding: .65em;' >PhoneNo</th>";
echo"<th style='border: 1px solid; padding: .65em;'>Contact Person</th>";
echo"</tr>";
echo"</thead>";
while($row = mysqli_fetch_array($result))
{
echo"<tbody>";
echo"<tr>";
echo "<td style=' padding: .65em;'>" . $row['co_name'] . "</td>";
echo "<td style=' padding: .65em;'>" . $row['co_address'] . "</td>";
echo "<td style=' padding: .65em;'>" . $row['co_website'] . "</td>";
echo "<td style=' padding: .65em;'>" . $row['co_phoneno'] . "</td>";
echo "<td style=' padding: .65em;'>" . $row['co_contactperson'] . "</td>";
echo"</tr>";
echo"</tbody>";
}
echo"</table>";
mysqli_close($con);
?>
I have this table that is simple but i am not able to add colors through css to it, at present i have used inline css will convert it to external css later. i wish to show the table head with different color and the rows of the table that contain data should be of 2 colors that run alternatively. Would appreciate if someone could help me
P.S some people wanted to see my other sheet, here it is
<style>
table { border-collapse: collapse; font-family: Futura, Arial, sans-serif; border: 1px solid ; margin-left:180px; width:1000px; margin-top:30px;}
caption { font-size: larger; margin: 1em auto; }
th, td { padding: .65em; }
th, thead { background-color: ffecc4; border: 1px solid ; }
tr:nth-child(odd) { background: #ccc; }
tr:hover { background: #aaa; }
td { border-right: 1px solid #777; }
</style>
In html TABLE you cannot give background-color or color to <thead>. <thead> doesn't not take any colors. You can do..
#miyazaki thead th{
background-color:red;
color:#000;}
And for alternate colors you can apply
#miyazaki tr:nth-child(odd){
background: #b8d1f3;
}
#miyazaki tr:nth-child(even){
background: #dae5f4;
}
Do it with jquery:
<script>
$(document).ready(function() {
$("#miyazaki tr:even").css("background-color", "#CCC");
$("#miyazaki tr:odd").css("background-color", "#FFF");
});
</script>
You can do it with CSS:
#miyazaki tr:nth-child(even) {background: #CCC}
#miyazaki tr:nth-child(odd) {background: #FFF}
Reference
Note: No support in IE 8 for this.
Or, if you have jQuery:
<script>
$(document).ready(function() {
$("#miyazaki tr:even").css("background-color", "#CCC");
$("#miyazaki tr:odd").css("background-color", "#FFF");
});
</script>
if you add classes to you code e.g
`echo"<th style='border: 1px solid; padding: .65em;' class='tblHead'>Office Name</th>";`
and
`echo "<td style=' padding: .65em;'>" . $row['co_name'] . " class='tblRow' </td>";`
Then you can write some CSS to set styles for those classes.
like:
.tblHead {
background-color: yellow;
}
.tblRow{
background-color: green;
}
I want to run a foreach loop inside a msgHTML on PHP Mailer to make the table td dynamic from array. Below is the latest code I have. I' am working on dreamweaver and it show that this code has errors, I don't know how to solve this issue.
<?php
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$mail->MsgHTML(
"
Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
"
?>
<?php
foreach($variable as $var){
?>
<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
<?php
}
?>
<?php "
</table>
");
?>
How about this code?
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$msg = "Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
foreach($variable as $var){
$msg .= "<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
} // foreach
$msg .= "</table>";
$mail->MsgHTML( $msg );
try this
$mail->Subject = "Vacancy No: " . $vacancy_no . " - " . $vacancy_title;
$message =
"
Some html and text goes here....
Below is the main part of this topic.
<u><strong>Referees & Contact</strong></u><br/>
<table width='100%' border='0' cellpadding='0' cellspacing='0' style='border: 1px solid #E2E2E2;'>
<tr style='background: #003e82; color: #FFF; font-weight: bold;'>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>
";
foreach ($variable as $var) {
$message .= "<tr>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Name</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Position & Organization</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Phone Contact</td>
<td style='border: 1px solid #E2E2E2; height:30px; padding-left:5px; padding-right: 5px;'>Email</td>
</tr>";
}
$message .= "
</table>
";
$mail->MsgHTML($message);