Using include inside loop to send mail - php

I am trying to have my loop insert into the database 6 records automatically, the only thing that changes is the dates of these records, and whenever it enters it has to send an email with the always updated data, but the only one thing I got was to make it send only 1 email, and this email only has the last loop information.
The idea is to send an email whenever you insert it into the DB
Here is the code test:
<?php
$replace1="27-02-2019 00:00";
$replace2="27-02-2029 00:00";
$strStart = '2019-09-10';
$strEnd = '2029-09-10';
$dteStart = new DateTime($strStart);
$dteEnd = new DateTime($strEnd);
$dteDiff = $dteStart->diff($dteEnd);
$anos=$dteDiff->format("%Y");
$dias=$dteDiff->format("%d");
$meses=$dteDiff->format("%m");
$repete = ($anos * 12);
$rotina="6";
if($rotina == "6"){
$assunto = "Rotina Semestral";
$repete = ($repete / 6);
for($i = 0; $i <= $repete; $i++){
echo $i."==".$replace1." - ";
echo $replace2."<br>";
$replace1 = date('d-m-Y H:m',strtotime($replace1." +6 Months"));
include('email1.php');
};
}elseif($rotina == "3"){
//code...
};
}elseif($rotina == "1"){
$repete = $anos;
for($i = 0; $i <= $repete; $i++){
//code...
};
};
Here is email1.php:
<?php
$path = $_SERVER['DOCUMENT_ROOT'] . '\dist\PHPMailer_5.2.0\\';
$file = $path . 'class.phpmailer.php';
include($file);
$mail = new PHPMailer();
$mail->CharSet = 'UTF8';
$mail->IsSMTP();
$mail->Host = "$smtp";
$mail->SMTPAuth = false;
$mail->From = "$emailhost";
$mail->FromName = "Nova tarefa SIGMA ";
$mail->AddAddress ($email_post);
$mail->WordWrap = 99999;
$mail->IsHTML(true);
$mail->Subject = "Nova tarefa SIGMA WO/NF/ID Cliente: ".$won1;
$mail->AddEmbeddedImage('img/baixo.png', 'baixo');
$mail->Body = "<div style='margin-left:0px; padding:0px;width:800px;height:772px;style='color:#3366FF;'>
<h1 style='text-align: center; background-color:#0B95ED; color:#FFFFFF;font-family: Arial, Helvetica, sans-serif;line-height:2.5em;'>Informação do Pedido - Novo Pedido</h1>
<hr><br>
<!-- texto entre linhas -->
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='50%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>WO/NF/ID Cliente:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- WO/NF/ID Cliente: -->
$won
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Responsável do pedido:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- Responsável do pedido: -->
$res_2
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Técnico 1:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- Técnico 2: -->
$tec1_1
</td>
</tr>
</table>
</td>
<td align='center' valign='top' width='50%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<b> Cliente:
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
$cli
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<font color='#B0C4DE'>Vazio</font>
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
<font color='#FFFFFF'>Vazio</font>
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<b>Técnico 2:
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
$tec2_2
</td>
</tr>
</table>
</td>
</table>
<table border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='100%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Descrição da Tarefa:
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='100%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor=''>
<div class='b'>
$descre
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div>
</div>
<hr>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><center>
<div>
<!--[if mso]>
<v:roundrect xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w='urn:schemas-microsoft-com:office:word' href='http://sigma.eda.pt' style='height:36px;v-text-anchor:middle;width:150px;' arcsize='5%' strokecolor='#EB7035' fillcolor='#EB7035'>
<w:anchorlock/>
<center style='color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;'>Bom Trabalho! →</center>
</v:roundrect>
<![endif]-->
<a href='http://sigma.eda.pt' style='background-color:#EB7035;border:1px solid #EB7035;border-radius:3px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:16px;line-height:44px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;mso-hide:all;'>Bom Trabalho! →</a>
</div>
</td>
</tr>
</table>
";
$mail->Send();

I cant't test it for the moment but the new file will be something like this
<?php
$path = $_SERVER['DOCUMENT_ROOT'] . '\dist\PHPMailer_5.2.0\\';
$file = $path . 'class.phpmailer.php';
**include_once($file);**
function my_send_mail($smtp,$emailhost,$email_post,$won1,$won,$res_2,$tec1_1,$cli,$tec2_2,$descre){
$mail = new PHPMailer();
$mail->CharSet = 'UTF8';
$mail->IsSMTP();
$mail->Host = "$smtp";
$mail->SMTPAuth = false;
$mail->From = "$emailhost";
$mail->FromName = "Nova tarefa SIGMA ";
$mail->AddAddress ($email_post);
$mail->WordWrap = 99999;
$mail->IsHTML(true);
$mail->Subject = "Nova tarefa SIGMA WO/NF/ID Cliente: ".$won1;
$mail->AddEmbeddedImage('img/baixo.png', 'baixo');
$mail->Body = "<div style='margin-left:0px; padding:0px;width:800px;height:772px;style='color:#3366FF;'>
<h1 style='text-align: center; background-color:#0B95ED; color:#FFFFFF;font-family: Arial, Helvetica, sans-serif;line-height:2.5em;'>Informação do Pedido - Novo Pedido</h1>
<hr><br>
<!-- texto entre linhas -->
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='50%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>WO/NF/ID Cliente:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- WO/NF/ID Cliente: -->
$won
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Responsável do pedido:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- Responsável do pedido: -->
$res_2
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Técnico 1:
</td>
</tr>
<tr>
<td class='leftColumnContent' bgcolor=''>
<!-- Técnico 2: -->
$tec1_1
</td>
</tr>
</table>
</td>
<td align='center' valign='top' width='50%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<b> Cliente:
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
$cli
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<font color='#B0C4DE'>Vazio</font>
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
<font color='#FFFFFF'>Vazio</font>
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor='#B0C4DE'>
<b>Técnico 2:
</td>
</tr>
<tr>
<td class='rightColumnContent' bgcolor=''>
$tec2_2
</td>
</tr>
</table>
</td>
</table>
<table border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='100%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor='#B0C4DE'>
<b>Descrição da Tarefa:
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' width='100%' id='templateColumns'>
<tr>
<td align='center' valign='top' width='100%' class=' '>
<table border='0' cellpadding='10' cellspacing='0' width='100%'>
<tr>
<td class='leftColumnContent' bgcolor=''>
<div class='b'>
$descre
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div>
</div>
<hr>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><center>
<div>
<!--[if mso]>
<v:roundrect xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w='urn:schemas-microsoft-com:office:word' href='http://sigma.eda.pt' style='height:36px;v-text-anchor:middle;width:150px;' arcsize='5%' strokecolor='#EB7035' fillcolor='#EB7035'>
<w:anchorlock/>
<center style='color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;'>Bom Trabalho! →</center>
</v:roundrect>
<![endif]-->
<a href='http://sigma.eda.pt' style='background-color:#EB7035;border:1px solid #EB7035;border-radius:3px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:16px;line-height:44px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;mso-hide:all;'>Bom Trabalho! →</a>
</div>
</td>
</tr>
</table>
";
$mail->Send();
}
and your default file will be
<?php
include('email1.php');
$replace1="27-02-2019 00:00";
$replace2="27-02-2029 00:00";
$strStart = '2019-09-10';
$strEnd = '2029-09-10';
$dteStart = new DateTime($strStart);
$dteEnd = new DateTime($strEnd);
$dteDiff = $dteStart->diff($dteEnd);
$anos=$dteDiff->format("%Y");
$dias=$dteDiff->format("%d");
$meses=$dteDiff->format("%m");
$repete = ($anos * 12);
$rotina="6";
switch($rotina){
case "6":
$assunto = "Rotina Semestral";
$repete = ($repete / 6);
for($i = 0; $i <= $repete; $i++){
echo $i."==".$replace1." - ";
echo $replace2."<br>";
$replace1 = date('d-m-Y H:m',strtotime($replace1." +6 Months"));
my_send_mail($smtp,$emailhost,$email_post,$won1,$won,$res_2,$tec1_1,$cli,$tec2_2,$descre);
};
break;
case "3":
//code...
break;
case "1":
$repete = $anos;
for($i = 0; $i <= $repete; $i++){
//code...
};
break;
}
But i don't know where you take the variable used inside the file mail1.php
I don't know what php lib you are using for sendmail but implemente exceptions in mail send http://php.net/manual/en/language.exceptions.php
Sorry for my bad english
Replace
$mail->Send()
whit this
try {
if ( !$mail->Send() ) {
$error = "Unable to send to: " . $to . "<br />";
throw new phpmailerAppException($error);
} else {
echo 'Message has been sent using <?php echo strtoupper($_POST['test_type']); ?><br /><br />';
}
} catch (phpmailerAppException $e) {
$errorMsg[] = $e->errorMessage();
}
if ( count($errorMsg) > 0 ) {
foreach ($errorMsg as $key => $value) {
$thisError = $key + 1;
echo $thisError . ': ' . $value;
}
}

Related

How to change date into name

The code below works, but I want to change the months into names, such as "October", "November" and "December" using MONTHNAME. When I do, I get an error like the following:
JulyError in query: unknown column 'July' in 'where clause'.
What am I doing wrong?
<html>
<body>
<?php
$connection = mysql_connect('localhost','root','') or die ('unable to connect');
mysql_select_db("naurah")or die ("cannot select db");
$query = "SELECT YEAR(date) AS year, SUM(total) AS total FROM `order` GROUP BY year";
$result = mysql_query($query) or die ("Error in query:".mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row=mysql_fetch_array($result)) {
echo $row[0];
$query1 = "SELECT * FROM `order` WHERE YEAR(date) = $row[0]";
$result1=mysql_query($query1) or die ("Error in query:".mysql_error());
if (mysql_num_rows($result1) > 0) {
echo '<table border="1" cellpadding="0" cellspacing="0" class="tg">
<strong>
<tr>
<th class="tg-031e">Order ID</th>
<th class="tg-031e" width="100">Date</th>
<th class="tg-031e">Name</th>
<th class="tg-031e">Email</th>
<th class="tg-031e" width="100">Telephone</th>
<th class="tg-031e">Address</th>
<th class="tg-031e">City</th>
<th class="tg-031e">Postcode</th>
<th class="tg-031e">State</th>
<th class="tg-031e">Reference No</th>
<th class="tg-031e">Total</th>
<th class="tg-031e">Order Status</th>
<th class="tg-031e">Postage</th>
<th class="tg-031e">Action</th>
</tr>
</strong>';
while ($row1 = mysql_fetch_array($result1)) {
echo "
<tr>
<td class=\"tg-4eph\" ><div align=\"center\"> $row1[0] </div></td>
<td class=\"tg-031e\" ><div align=\"center\"> $row1[1] </div></td>
<td class=\"tg-031e\" ><div align=\"center\">$row1[3] $row1[2]</div></td>
<td class=\"tg-4eph\" ><div align=\"center\"> $row1[4]</div></td>
<td class=\"tg-031e\" ><div align=\"center\"> $row1[5]</div></td>
<td class=\"tg-4eph\" ><div align=\"center\"> $row1[6]</div></td>
<td class=\"tg-031e\" ><div align=\"center\"> $row1[7]</div></td>
<td class=\"tg-4eph\" ><div align=\"center\"> $row1[8]</div></td>
<td class=\"tg-031e\"><div align=\"center\"> $row1[9]</div></td>
<td class=\"tg-031e\"><div align=\"center\"> $row1[10]</div></td>
<td class=\"tg-031e\"><div align=\"center\"> $row1[11]</div></td>
<td class=\"tg-031e\"><div align=\"center\"> $row1[12]</div></td>
<td class=\"tg-031e\"><div align=\"center\"> $row1[13]</div></td>
<td class=\"tg-4eph\" width=\"100\"><div align=\"center\">
<a href=\"adminupdatetrans.php?orderID= $row1[0]\">
<img src=\"../images/icn_edit_article.png\" title=\"Remove\"/>
</a>
<a href=\"admindeleteorder.php?orderID= $row1[0] \" onclick=\"return confirm('Are you sure want to delete ?')\">
<img src=\"../images/icn_trash.png\" title=\"Remove\"/>
</a>
</td>
</tr>
";
}
echo '
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td >Total All:</td>
';
echo '<td>RM';
echo $row[1];
echo '</td></tr>';
echo '</table>';
}
}
}
?>
</body>
</html>
Assuming that the date is in a timestamp format :),
You can get the names of months thanks to this method :
date("F",mktime(0,0,0,date('m', $timestamp),1,2011));Or like this :
date('F', strtotime("2015-date('m', $timestamp)-01"));

Creating PDF with TCPDF shows Undefined index: cols in tcpdf/tcpdf.php on line 16928

I wanted to use TCPDF to generate a PDF report. but every time it shows me error on line 16928 and I can't understand what to do...
It would be great if you could help me
here is my code:
<?php
$html = "
<html>
<head>
<link rel='stylesheet' href='form.css'>
</head>
<body>
<div class='header'>
<h4>وزارت بهداشت، درمان و آموزش کشور</h4>
<h4>Ministry of Health & Medical Education</h4>
<table>
<tr>
<td class='engterm'>University of medical science:</td><td class='val'>[SAMPLE_ECHO]</td><td class='perterm'>دانشگاه علوم پزشکی:</td>
</tr>
<tr>
<td class='engterm'>Medical center:</td><td class='val'>[SAMPLE_ECHO]</td><td class='perterm'>مرکز پزشکی آموزشی درمانی:</td>
</tr>
</table>
</div>
<div class='body'>
<table class='main' border='1'>
<tr>
<td class='main' colspan='1' rowspan='2' style='text-align: left;'>
<table style='margin: 0 auto;'>
<tr>
<td class='engterm'>Clinic no.:</td><td class='val'>[sample]</td><td class='perterm'>شماره درمانگاهی:</td>
</tr>
</table>
</td>
<td class='main' colspan='2' rowspan='2' style='text-align: center; width: 50%'>
<h4>برگ خلاصه پرونده</h4>
<h4>Unit Summery Sheet</h4>
</td>
<td class='main' colspan='1' rowspan='2' style='direction: ltr;'>
<table style='margin: 0 auto;'>
<tr>
<td class='engterm'>Unit no.:</td><td class='val'>[sample]</td><td class='perterm'>شماره پرونده:</td>
</tr>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td class='main' rowspan='1'>
<table class='data'>
<td>Attending Physician:</td><td>SampleData</td><td>پزشک معالج:</td>
</table>
</td>
<td class='main' rowspan='2'>
<table class='data'>
<tr><td>Ward:</td><td>Sample</td><td>بخش:</td></tr>
<tr><td>Room:</td><td>Sample</td><td>اتاق:</td></tr>
<tr><td>Bed:</td><td>Sample</td><td>تخت:</td></tr>
</table>
</td>
<td class='main' rowspan='1'>
<table class='data'>
<td>Name:</td><td>Sample</td><td>نام:</td>
</table>
</td>
<td class='main' rowspan='1'>
<table class='data'>
<td>Family name:</td><td>Sample</td><td>نام خانوادگی:</td>
</table>
</td>
</tr>
<tr>
<td class='main'>
<table class='data'>
<td>Admission date:</td><td>Sample</td><td>تاریخ پذیرش:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Date of Birth:</td><td>Sample</td><td>تاریخ تولد:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Father's name:</td><td>Sample</td><td>نام پدر:</td>
</table>
</td>
</tr>
<tr>
<td class='main'>
<table class='data'>
<td></td><td>Sample</td><td>تاریخ ترخیص:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Occupation:</td><td>Sample</td><td>شغل:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Marriage status:</td>
<td>
<input type='radio' name='marriage_status' value='married'>متاهل / Married<br>
<input type='radio' name='marriage_status' value='single'>مجرد / Single
</td>
<td>وضعیت تاهل:</td>
</table>
</td>
<td class='main'>
<table class='data'>
<td>Sex:</td>
<td>
<input type='radio' name='sex' value='male'>مرد / Male<br>
<input type='radio' name='sex' value='female'> زن / Female
</td>
<td>جنسیت:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1' style='text-align: left;'>Address:</td><td colspan='2'>Sample</td><td colspan='1' style='text-align: right;'>آدرس:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Final Diagnosis:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>تشخصی نهایی:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Medical & Surgical Procedures:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>اقدامات درمانی و اعمال جراحی:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Results of Paraclinical Examination:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>پاراكلينيكي آزمايشات نتايج:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Disease Progress (Cause of Death):</td>
<td colspan='2'>Sample</td>
<td colspan='1'>سیر بیماری (درصورت فوت، علت مرگ):</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Patient's Condition on Discharge:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>وضعیت بیمار هنگام ترخیض:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Recommendations after discharge:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>توصیه‌های پس از ترخیض:</td>
</table>
</td>
</tr>
<tr>
<td colspan='4'>
<table class='data'>
<td colspan='1'>Attending Physician's Name & Signature:</td>
<td colspan='2'>Sample</td>
<td colspan='1'>نام و امضا پزشک معالج:</td>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>";
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
if (#file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->SetFont('helvetica', '', 9);
$pdf->AddPage();
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->lastPage();
$pdf->Output('htmlout.pdf', 'I');
?>
When reading the page from web server, it shows me the following error:
Notice: Undefined index: cols in /home/aien/public_html/Arash.Sammak/JSON Return/tcpdf/tcpdf.php on line 16928
You have to add a valid <thead> element to every table. TCPDF parses the <thead> element to determine the number of columns in a table when it outputs tables in PDF.
Also, check your HTML twice is valid or not if some other errors keep occurring.
Hope this helps.

How can if statement be used within echo

I have to check the results that are coming from fetch array, I am using else if or if to get the remarks. But I do not know how to use it with in echo, When I run this code all the remarks statements come in same form as written in code.
In this I have to check the results that is coming from fetch array, so for this I am using else if or if to get the remarks..but i am do not know how to use it with in echo. When I run this code all the remarks statements come in same form as written in code
Code:
<?php
$answer = '';
include('config.php');
if(isset($_GET["results"]))
$answer = $_GET["results"];
$id = $_GET["idk"];
switch ($answer)
{
case 'Nursery':
$qqqs = mysql_query("select * from result where u_id='$id' AND sc='Nursery' ");
$rows=mysql_fetch_assoc($qqqs);
$a=$rows['u_id'];
$b=$rows['name'];
$c=$rows['fname'];
$d=$rows['reg'];
$e=$rows['sc'];
$f=$rows['ss'];
$g=$rows['se'];
$h=$rows['e1'];
$i=$rows['u1'];
$j=$rows['m1'];
$k=$rows['s1'];
$l=$rows['ss1'];
$m=$rows['i1'];
$n=$rows['e2'];
$o=$rows['u2'];
$p=$rows['e3'];
$pp=$rows['u3'];
$pic=$rows['picture'];
$total=$h+$i+$j+$k+$l+$m+$n+$o+$p;
$totals=230;
$res = ( $totals / $total) * 100;
// 0 digit after the decimal point
$res = round($res); // 67
// 1 digit after the decimal point
$res = round($res, 1); // 66.7
// 2 digits after the decimal point
$res = round($res, 2); // 66.67
echo "<html>
<head>
</head>
<body>
<table align='center' border='4' bgcolor='white' width='500' class='table table-bordered'>
<tr>
<td bgcolor='orange' colspan='4'><h2 align='center'>Leads Grammar School</h2><p align='center'>Babar Road, Kirri Jamandan, Multan</p></td>
</tr>
<tr>
<td bgcolor='yellow' colspan='4'><h2 align='center'>Monthly Test Feb-March</h2></td>
</tr>
<tr>
<td colspan='2'><img src='images/$pic' width='100px' height='100px' align='right'></td>
</tr>
<tr>
<td align='right'>Student's Name</td>
<td colspan='3'>$b</td>
</tr>
<tr>
<td align='right'>Father's Name</td>
<td colspan='3'> $c</td>
</tr>
<tr>
<td align='right'>Registration</td>
<td colspan='3'>$d</td>
</tr>
<tr>
<td align='right'>Student Class</td>
<td colspan='3'>$e</td>
</tr>
<tr>
<td align='right'>Exams</td>
<td colspan='3'>$f</td>
</tr>
<tr bgcolor='gray'>
<th>Subject Name</th>
<th>Marks</th>
<th>Obtained Marks</th>
<th>Grades</th>
</tr>
<tr>
<tr><td>English(Writing)</td>
<td>50</td>
<td> $h</td>
</tr>
<tr>
<tr ><td>Urdu(Writing)</td>
<td>50</td>
<td>$i</td>
</tr>
<tr>
<tr ><td>Math(Writing)</td>
<td>50</td>
<td> $j</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>General Knowledge</th></tr>
<tr>
<tr ><td>Science</td>
<td>10</td>
<td> $k</td>
</tr>
<tr>
<tr ><td>S.Studies</td>
<td>10</td>
<td>$l</td>
</tr>
<tr>
<tr ><td>Islamiat</td>
<td>10</td>
<td>$m</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Poems</th></tr>
<tr>
<tr ><td>English </td>
<td>15</td>
<td> $n</td>
</tr>
<tr>
<tr ><td>Urdu</td>
<td>15</td>
<td>$o</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Book Reading</th></tr>
<tr>
<tr><td>English </td>
<td>10</td>
<td>$p</td>
</tr>
<tr>
<tr >
<td>Urdu</td>
<td>10</td>
<td>$pp</td>
</tr>
<tr>
<td><h1>Total Marks</h1></td>
<td>230</td>
<td>$total</td>
<td>$res</td>
</tr>
<tr><td><h2>Remarks</h2></td>
<td colspan='3'>
if(91=<$res<=100)
{
echo 'Exceptional';
}
else if(81=<$res<=90)
{
echo 'Excellent';
}
else if(71=<$res<=80)
{
echo 'Very Good';
}
else if(61=<$res<=70)
{
echo 'Good';
}
else if(51=<$res<=60)
{
echo 'Fair';
}
else if(40=<$res<=50)
{
echo 'Pass';
}
else if(01=<$res<=39)
{
echo ' Needs Improvement';
}
else if($res==0)
{
echo ' Needs Improvement';
}
</td>
</tr>
";
break;
}
?>
Try this:
<?php
$answer = '';
include('config.php');
if(isset($_GET["results"]))
$answer = $_GET["results"];
$id = $_GET["idk"];
switch ($answer)
{
case 'Nursery':
$qqqs = mysql_query("select * from result where u_id='$id' AND sc='Nursery' ");
$rows=mysql_fetch_assoc($qqqs);
$a=$rows['u_id'];
$b=$rows['name'];
$c=$rows['fname'];
$d=$rows['reg'];
$e=$rows['sc'];
$f=$rows['ss'];
$g=$rows['se'];
$h=$rows['e1'];
$i=$rows['u1'];
$j=$rows['m1'];
$k=$rows['s1'];
$l=$rows['ss1'];
$m=$rows['i1'];
$n=$rows['e2'];
$o=$rows['u2'];
$p=$rows['e3'];
$pp=$rows['u3'];
$pic=$rows['picture'];
$total=$h+$i+$j+$k+$l+$m+$n+$o+$p;
$totals=230;
$res = ( $totals / $total) * 100;
// 0 digit after the decimal point
$res = round($res); // 67
// 1 digit after the decimal point
$res = round($res, 1); // 66.7
// 2 digits after the decimal point
$res = round($res, 2); // 66.67
$out = "<html>
<head>
</head>
<body>
<table align='center' border='4' bgcolor='white' width='500' class='table table-bordered'>
<tr>
<td bgcolor='orange' colspan='4'><h2 align='center'>Leads Grammar School</h2><p align='center'>Babar Road, Kirri Jamandan, Multan</p></td>
</tr>
<tr>
<td bgcolor='yellow' colspan='4'><h2 align='center'>Monthly Test Feb-March</h2></td>
</tr>
<tr>
<td colspan='2'><img src='images/$pic' width='100px' height='100px' align='right'></td>
</tr>
<tr>
<td align='right'>Student's Name</td>
<td colspan='3'>$b</td>
</tr>
<tr>
<td align='right'>Father's Name</td>
<td colspan='3'> $c</td>
</tr>
<tr>
<td align='right'>Registration</td>
<td colspan='3'>$d</td>
</tr>
<tr>
<td align='right'>Student Class</td>
<td colspan='3'>$e</td>
</tr>
<tr>
<td align='right'>Exams</td>
<td colspan='3'>$f</td>
</tr>
<tr bgcolor='gray'>
<th>Subject Name</th>
<th>Marks</th>
<th>Obtained Marks</th>
<th>Grades</th>
</tr>
<tr>
<tr><td>English(Writing)</td>
<td>50</td>
<td> $h</td>
</tr>
<tr>
<tr ><td>Urdu(Writing)</td>
<td>50</td>
<td>$i</td>
</tr>
<tr>
<tr ><td>Math(Writing)</td>
<td>50</td>
<td> $j</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>General Knowledge</th></tr>
<tr>
<tr ><td>Science</td>
<td>10</td>
<td> $k</td>
</tr>
<tr>
<tr ><td>S.Studies</td>
<td>10</td>
<td>$l</td>
</tr>
<tr>
<tr ><td>Islamiat</td>
<td>10</td>
<td>$m</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Poems</th></tr>
<tr>
<tr ><td>English </td>
<td>15</td>
<td> $n</td>
</tr>
<tr>
<tr ><td>Urdu</td>
<td>15</td>
<td>$o</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Book Reading</th></tr>
<tr>
<tr><td>English </td>
<td>10</td>
<td>$p</td>
</tr>
<tr>
<tr >
<td>Urdu</td>
<td>10</td>
<td>$pp</td>
</tr>
<tr>
<td><h1>Total Marks</h1></td>
<td>230</td>
<td>$total</td>
<td>$res</td>
</tr>
<tr><td><h2>Remarks</h2></td>
<td colspan='3'>";
if(91=<$res<=100)
{
$out .= 'Exceptional';
}
else if(81=<$res<=90)
{
$out .= 'Excellent';
}
else if(71=<$res<=80)
{
$out .= 'Very Good';
}
else if(61=<$res<=70)
{
$out .= 'Good';
}
else if(51=<$res<=60)
{
$out .= 'Fair';
}
else if(40=<$res<=50)
{
$out .= 'Pass';
}
else if(01=<$res<=39)
{
$out .= ' Needs Improvement';
}
else if($res==0)
{
$out .= ' Needs Improvement';
}
$out .="</td></tr>";
echo $out;
break;
}
?>
PHP does not have support for this syntax:
if(01=<$res<=39)
Instead you'll have to do this:
if(1 <= $res && $res <= 39)
Also, don't start your numbers with a 0 or they'll be interpreted as octal numbers (base 8) which will have some strange consequences.
EDIT upon closer inspection
Oh... additionally you indeed cannot have conditional statements inside an echo. You'll have to build the whole string in code first, and then echo it.
Simply end your first echo and then use your if statement to echo the remaining of the table.
<?php
$answer = '';
include('config.php');
if(isset($_GET["results"]))
$answer = $_GET["results"];
$id = $_GET["idk"];
switch ($answer)
{
case 'Nursery':
$qqqs = mysql_query("select * from result where u_id='$id' AND sc='Nursery' ");
$rows=mysql_fetch_assoc($qqqs);
$a=$rows['u_id'];
$b=$rows['name'];
$c=$rows['fname'];
$d=$rows['reg'];
$e=$rows['sc'];
$f=$rows['ss'];
$g=$rows['se'];
$h=$rows['e1'];
$i=$rows['u1'];
$j=$rows['m1'];
$k=$rows['s1'];
$l=$rows['ss1'];
$m=$rows['i1'];
$n=$rows['e2'];
$o=$rows['u2'];
$p=$rows['e3'];
$pp=$rows['u3'];
$pic=$rows['picture'];
$total=$h+$i+$j+$k+$l+$m+$n+$o+$p;
$totals=230;
$res = ( $totals / $total) * 100;
// 0 digit after the decimal point
$res = round($res); // 67
// 1 digit after the decimal point
$res = round($res, 1); // 66.7
// 2 digits after the decimal point
$res = round($res, 2); // 66.67
echo "<html>
<head>
</head>
<body>
<table align='center' border='4' bgcolor='white' width='500' class='table table-bordered'>
<tr>
<td bgcolor='orange' colspan='4'><h2 align='center'>Leads Grammar School</h2><p align='center'>Babar Road, Kirri Jamandan, Multan</p></td>
</tr>
<tr>
<td bgcolor='yellow' colspan='4'><h2 align='center'>Monthly Test Feb-March</h2></td>
</tr>
<tr>
<td colspan='2'><img src='images/$pic' width='100px' height='100px' align='right'></td>
</tr>
<tr>
<td align='right'>Student's Name</td>
<td colspan='3'>$b</td>
</tr>
<tr>
<td align='right'>Father's Name</td>
<td colspan='3'> $c</td>
</tr>
<tr>
<td align='right'>Registration</td>
<td colspan='3'>$d</td>
</tr>
<tr>
<td align='right'>Student Class</td>
<td colspan='3'>$e</td>
</tr>
<tr>
<td align='right'>Exams</td>
<td colspan='3'>$f</td>
</tr>
<tr bgcolor='gray'>
<th>Subject Name</th>
<th>Marks</th>
<th>Obtained Marks</th>
<th>Grades</th>
</tr>
<tr>
<tr><td>English(Writing)</td>
<td>50</td>
<td> $h</td>
</tr>
<tr>
<tr ><td>Urdu(Writing)</td>
<td>50</td>
<td>$i</td>
</tr>
<tr>
<tr ><td>Math(Writing)</td>
<td>50</td>
<td> $j</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>General Knowledge</th></tr>
<tr>
<tr ><td>Science</td>
<td>10</td>
<td> $k</td>
</tr>
<tr>
<tr ><td>S.Studies</td>
<td>10</td>
<td>$l</td>
</tr>
<tr>
<tr ><td>Islamiat</td>
<td>10</td>
<td>$m</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Poems</th></tr>
<tr>
<tr ><td>English </td>
<td>15</td>
<td> $n</td>
</tr>
<tr>
<tr ><td>Urdu</td>
<td>15</td>
<td>$o</td>
</tr>
<tr><th align='center' colspan='3' bgcolor='orange'>Book Reading</th></tr>
<tr>
<tr><td>English </td>
<td>10</td>
<td>$p</td>
</tr>
<tr>
<tr >
<td>Urdu</td>
<td>10</td>
<td>$pp</td>
</tr>
<tr>
<td><h1>Total Marks</h1></td>
<td>230</td>
<td>$total</td>
<td>$res</td>
</tr>
<tr><td><h2>Remarks</h2></td>
<td colspan='3'>";
if(91=<$res<=100)
{
echo 'Exceptional';
}
elseif(81=<$res<=90)
{
echo 'Excellent';
}
else if(71=<$res<=80)
{
echo 'Very Good';
}
elseif(61=<$res<=70)
{
echo 'Good';
}
elseif(51=<$res<=60)
{
echo 'Fair';
}
elseif(40=<$res<=50)
{
echo 'Pass';
}
else if(01=<$res<=39)
{
echo ' Needs Improvement';
}
elseif($res==0)
{
echo ' Needs Improvement';
}
echo "</td>";
echo "</tr>";
break;
}
?>
You can use the ternary operator for conditions within echo:
echo "start of string....".(bool_condition1 ? "condition is true" : "condition is false").".... more string";
Yes, you can have if/else conditions in an echo by concatenating:
$x = 10;
echo "X is " . ($x==10? "equal" : "not equal") . " to 10";
I would also recommend that you create a function that return the string evaluating the score.
Try to mix as little logic as possible with the presentation.
You can't have an if statement inside echo. What you can do is to move all your if's outside the echo, and store the result in a variable. Eg:
if(91 <= $res && $res <= 100) // Note how the condition *should* be written.
{
$remark = 'Exceptional';
}
else if(...
and then use the variable in your table output:
<tr><td><h2>Remarks</h2></td>
<td colspan='3'>$remark
You could also use ternary operators, in combination with a custom function:
echo "fixed part".(inbetween($res,91,100)?'Exceptional':(inbetween($res,81,90)?'Excellent':'SOMETHING ELSE'));
function inbetween($int,$min,$max)
{
return ($int>=$min && $int<=$max);
}
The syntax of this ternary operator can be seen in the following example:
echo "This is the result: " . ( $testiftrue ? 'TRUE' : 'FALSE' );
This will test the condition $testiftrue, and then display 'TRUE' or 'FALSE'

how to send styles with html email

I am using PHP mail() function to send the email. I have a table in the email with specific styles, but when I receeve the email, it does not show me the images and all style is disturbed.
My code is below:
$recipient = $_POST['Users']['email'];
$name = $_POST['Users']['first_name'];
$username = $_POST['Users']['username'];
$password = $_SESSION['password'];
$referrer_name = $model->referrer = $referrer_data['first_name'];
$referrer_email = $model->referrer = $referrer_data['email'];
// print_r($referrer_name);
// print_r($referrer_email);
$webstore = $this->base_url . "/" . Yii::app()->session['username'];
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$subject = "Sign Up- Success";
$message = "<table width='700' border='0' align='center' cellpadding='0' cellspacing='0' class='bordermain'>
<tr>
<td align='center' valign='middle'> </td>
</tr>
<tr>
<td align='center' valign='middle'><table width='666' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td width='666' colspan='2' align='center' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='50%' align='left' valign='middle'><img src='".$this->theme_baseurl."/images/karmora-websiteLogo.png' width='175' height='50' alt=''/></td>
<td width='50%' align='right' valign='middle'><table width='120' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='30' align='center' valign='middle'><a href='http://www.facebook.com/' target='_blank'><img src='".$this->theme_baseurl."/images/facebook.jpg' alt='Facebook' width='25' height='25' title='Facebook'/></a></td>
<td width='30' align='center' valign='middle'><a href='http://www.twitter.com/' target='_blank'><img src='".$this->theme_baseurl."/images/twitter.jpg' alt='Twitter' width='25' height='25' title='Twitter'/></a></td>
<td width='30' align='center' valign='middle'><a href='http://www.pinterest.com/' target='_blank'><img src='".$this->theme_baseurl."/images/pintrest.jpg' alt='Pinterest' width='25' height='25' title='Pinterest'/></a></td>
<td width='30' align='center' valign='middle'><a href='http://www.youtube.com/' target='_blank'><img border='0' width='25' height='25' src='".$this->theme_baseurl."/images/youtube.jpg' alt='YouTube'/></a></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan='2' align='left' valign='middle'> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan='2' align='center' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td align='center' valign='middle' bgcolor='#f9f9f9' style='border:1px solid #CCC;'><table width='99%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><span class='mainheading'><strong>Congratulations</strong></span></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan='2' align='center' valign='top' bgcolor='#FFFFFF'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='20' align='center' valign='middle'></td>
</tr>
<tr>
<td align='center' valign='middle' class='bodytext'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td valign='top' style='border-top:2px solid #FF7D0F'> </td>
</tr>
<tr>
<td align='left' valign='middle' class='bodytext'><p class='headingpink'><strong>Dear '$name'</strong></p>
<p>Congratulations on your decision to become the newest member of <strong>'$referrer_name' </strong>Karmora Community!</p>
<p>Below you will find important information about your new Karmora Webstore. Please print or save this email in a safe location for future reference.</p>
<table width='400' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='144'><strong><span class='bodytext'>Karmora URL</span></strong></td>
<td width='256'><strong><span class='bodytext'><a href='#'>'$webstore'</a></span></strong></td>
</tr>
<tr>
<td><strong><span class='bodytext'>User Name</span></strong></td>
<td><strong><span class='bodytext'>'$username'</span></strong></td>
</tr>
<tr>
<td><strong><span class='bodytext'>Password</span></strong></td>
<td><strong><span class='bodytext'>'$password'</span></strong></td>
</tr>
</table>
<p>Now it's time for you to start building your own personal Karmora Community where you can make money off the memberships and purchases of your Community members!  Let’s get this party started!</p>
<p class='headingpink'><strong>7 BABY STEPS TO GOOD KARMORA™:</strong></p>
<ol>
<li>Click on your Karmora URL and log in to your back office to customize your Webstore. You will see 'Log In' in the upper right hand corner of your Webstore.</li>
<li>Click on the Profile button and upload your picture while in the profile section. We recommend recent pictures. Your customers will want to know that it is your Webstore!</li>
<li>Go to the Training Section and watch the Instructional Videos. You will find all kinds of information to help you with your Karmora Webstore. </li>
<li>Click on the eWallet button and create your eWallet. Instructions on how to do this are found in the Training Section of your back office.</li>
<li>Use Go Daddy to secure a domain name for your new Webstore and point the new domain to your Karmora Webstore URL above. Instructions on how to do this are found in the Training Section of your back office </li>
<li>Make your first official Karmora purchase.</li>
<li>Start sharing your new Webstore with everyone you speak to so they can begin a Karmora Community of their own. Once you have five active members in your Karmora Community your Webstore is basically FREE!</li>
</ol>
<p>If you have any questions please don’t hesitate to contact <strong>'$referrer_name' </strong>by email at <a href='mailto:$referrer_email'>'$referrer_email'</a> or simply <u><a href='http://karmora.com/liveSupport'>click here</a></u> to chat with a Good Karmora™ Specialist seven days a week from 7am to 7pm Pacific Time. </p>
<p>As always we wish you Good Luck, Good Fortune and Good Karmora™! </p>
<p> </p>
</td>
</tr>
<tr>
<td align='left' valign='middle' style='border-bottom:2px solid #FF7D0F'> </td>
</tr>
</table></td>
</tr>
<tr>
<td align='center' valign='middle' class='bodytext'> </td>
</tr>
</table></td>
</tr>
<tr>
<td width='50%' height='70' align='center' valign='middle' bgcolor='#000000' class='footertextwhite' style='border-top:2px solid #de3277; border-bottom: 2px solid #de3277'><table width='90%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='40' align='left' valign='middle'><a href='http://karmora.com/contact' class='a1'>Contact Us<br />
</td>
</tr>
</table></td>
<td width='50%' height='70' align='center' valign='middle' bgcolor='#000000' class='footertextwhite' style='border-top:2px solid #de3277; border-bottom: 2px solid #de3277'><table width='90%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='40' align='right' valign='middle'><a href='http://www.karmora.com/liveSupport/'><img src='".$this->theme_baseurl."/images/live_support_icon_03.png' width='110' height='32' /></a><br />
<span class='footertext'>© 2013 Karmora</span></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan='2' align='center' valign='top'> </td>
</tr>
</table></td>
</tr>
</table>";
mail($recipient, $subject, $message,$headers);
You can put your styles inline in your elements
<p style="color:#000">...</p>
And you should use the PHP header
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
The reason you cannot use css other than inline and you are best advised to use table based layouts is that some if not most of the email clients such as outlook for example have VERY VERY old version of the browser embeded in them to show an html email.
So unfortunately all email has to be created like we were back in the days of IE6 or before.
As to your images not showing that is because you have to remember when the email is being read it is not a page on your website, so any images must have a fully defined domain and path like src="http://www.yoursite.net/images/facebook.jpg

Pulling last years data from a table

Hello I'm trying to update this scholarship application box. However when the year changed to 2013 it only displays scholarship applicant info from 2013. I'd like it to display info from 2012. I tried messing around with the date but I cant seem to figure it out. Any help would be greatly appreciated!
<?php
$appYear = date("Y").'-'.(date("Y")+1);
$sql = 'select * from sApplication where studentID = "'.$database->iPrep($_SESSION['ID']).'" AND appYear = "'.$appYear.'" LIMIT 1';
$appID = Scholarship::iFindSQL($sql);
$total = count($appID);
if ($total > 0)
{
$app = array_shift($appID);
}
else
{
$app = 0;
}
?>
<li id="item-2">
<div id="appStatus">
<h3>Application Status</h3>
<blockquote>
<?php if ($app->submitted == ('0000-00-00') || !isset($app->submitted)) { ?>
<table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="50%"><strong>Scholarship<br /> 2013-2014</strong></td>
<td width="50" align="right"> <a style="font-size:16px;" href="welcome.php? app=Scholar">Apply Now</a></td>
</tr>
<tr>
<td><strong>Date Submitted</strong></td>
<td align="right"> </td>
</tr>
<tr>
<td><strong>References</strong></td>
<td align="right"> </td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td> </td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td><strong>Scholarship 2012-2013</strong></td>
<td> </td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td> </td>
</tr>
</table>
<?php } else { ?>
<table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="90%"><strong>Scholarship 2013-2014</strong></td>
<td width="10%" align="right"> </td>
</tr>
<tr>
<td><strong>Date Submitted</strong></td>
<td align="right"><?=dbOutDate($app->submitted)?></td>
</tr>
<tr>
<td><strong>References</strong> </td>
<td align="right"></td>
</tr>
<tr>
<td colspan="2">
<?php
$refs = Reference::iFindSQL("Select * from reference where appID = '".$app->ID."'");?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php foreach($refs as $ref) { ?>
<tr> <td> <small><?php if($ref->rType == 'Academic Reference'){ echo 'Academic/Artistic/Professional'; } else { echo 'Community Service'; } ?></small></td> <td align="right"><?=$ref->status?></td></tr>
<?php } ?>
</table>
</td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td align="right">
<?php
if ($app->complete == 'Approved') { echo 'Approved'; }
if ($app->complete == 'Declined') { echo 'Declined'; }
if ($app->complete == 'Pending') { echo 'Pending'; }
if ($app->complete == 'Incomplete') { echo 'Incomplete'; }
Remove the WHERE clause that limits the year. Use ORDER BY to sort by year, descending.
$sql = 'select * from sApplication
where studentID = "'.$database->iPrep($_SESSION['ID']).
'" ORDER BY appYear DESC LIMIT 1';

Categories