I'm a novice when it comes to generating pdf files
I've tried tcpdf and mpdf but not getting the format the way i want it be.
Here's my mpdf code
include('./mpdf.php');
$mpdf=new mPDF();
$html = '<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="cssForTable.css">
</head>
<body>
<table>
<thead>
<tr>
<th width="25%">Client Details</th>
<th colspan="2" width="50%"><h2 style="padding-top: 0; margin-bottom: 0; margin-top: 0;text-align: center"><strong>ROAD TRAFFIC ACCIDENT</strong></h2></th>
<th width="25%">Legal HQ</th>
</tr>
</thead>
<tbody>
<tr>
<td width="50%" colspan="2">
<strong>Instructed Another Solicito?</strong>
Yes <input type="checkbox" /> No <input type="checkbox" />
</td>
<th width="50%" colspan="2" rowspan="3">
Claiming For:<br />
Personal Injury Yes <input type="checkbox" style="margin-bottom: 7px;" />
No <input type="checkbox" style="margin-bottom: 7px;" /><br />
Vehicle Damage Yes <input type="checkbox" style="margin-bottom: 7px;" />
No <input type="checkbox" style="margin-bottom: 7px;" /><br />
Loss of Earnings Yes <input type="checkbox" />
No <input type="checkbox" />
</th>
</tr>
<tr><th colspan="2"><h3 style="padding-top: 0; margin-bottom: 0; margin-top: 0;">ACCIDENT DETAILS</h3></th></tr>
<tr>
<th width="25%">Date of Accident</th>
<td width="25%"> </td>
</tr>
<tr>
<th width="25%">Time of Accident</th>
<td width="25%"> </td>
<th width="25%">No of Occupants (inc driver)</th>
<td width="25%"> </td>
</tr>
<tr>
<th width="25%">Location of Accident</th>
<td width="25%"> </td>
<td width="50%" colspan="2" rowspan="2" valign="top" >
<strong>Were Police Involved?
Yes <input type="checkbox" />
No <input type="checkbox" />
<br />
<br />If so, Police No/Station: </strong>
</td>
</tr>
<tr>
<td width="25%" colspan="2" rowspan="2" valign="top"><strong>Accident Circumstances</strong><br /><br /></td>
</tr>
<tr>
<th width="25%" colspan="2">
Is Client:<br />
Owner <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
Driver <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
Passenger <input type="checkbox" style="margin-left: 13em;" />
</th>
</tr>
<tr>
<th width="25%">Weather Conditions</th>
<th width="75%" colspan="3">
<label style="margin-left: 2em; margin-bottom: 7px;" > Sunny <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Rain <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Snow <input type="checkbox" /></label><br />
<label style="margin-left: 2em; margin-bottom: 7px;" > Ice <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Fog <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Dark <input type="checkbox" /></label>
</th>
</tr>
</tbody>
</table>
</body>
</html>';
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
The above code generates the following PDF file (screen shot)
Where as it should look like the following
My question is, is there a way to generate PDF as we generate HTML I mean is there a way to print whatever html+PHP has generated on client side?
Any Idea?
HTML2PDF converters may be overstrained with that layout. You may should consider PDF-Generators with more powerful layout-options.
The downside is, that you have to define your layout in another layout-language, but this will guarantee a satisfying output.
Have you considered to use XSL/FO with a suitable generator like PDFnow?
Yes, you can do this. Here is the complete code.
It works perfectly.
You can get value from another page using post method also. Your choice.
<?php $student_id = $_GET['student_id']; ?>
<?php
include("mpdf/mpdf.php");
$html .= "
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
background-image: url(\"images/ok.jpg\");
background-repeat: no-repeat;
padding-top:10pt;
margin-top: 100px;
padding-top: 50px;
}
td { vertical-align: top;
border-left: 0.6mm solid #000000;
border-right: 0.6mm solid #000000;
align: center;
}
p.student_id{
padding-left : 140px;
padding-top : -27px;
}
</style>
</head>
<body>
<!--mpdf
<p class=\"student_id\">$student_id</p>
<sethtmlpageheader name='myheader' value='on' show-this-page='1' />
<sethtmlpagefooter name='myfooter' value='on' />
mpdf-->
</body>
</html>
";
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('fullpage');
$mpdf->Output();
?>
Related
Delivery address is not adding in pdf invoice in prestashop.
I create a store on prestashop, but in its pdf invoice delivery address is missing.
How can i add the delivery address in the pdf invoice?
Please help me to fix this problem.
<!-- invoicing -->
<tr>
<td colspan="12">
{$addresses_tab}
</td>
</tr>
The delivery address block does not show if delivery address is same as invoice address.
If you want to display this block you can edit the template file invoice.tpl
and replace :
{if !empty($delivery_address)}
<table style="width: 100%">
<tr>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Delivery Address' pdf='true'}</span><br />
{$delivery_address}
</td>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing Address' pdf='true'}</span><br />
{$invoice_address}
</td>
</tr>
</table>
{else}
<table style="width: 100%">
<tr>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing & Delivery Address.' pdf='true'}</span><br />
{$invoice_address}
</td>
<td style="width: 50%">
</td>
</tr>
</table>
{/if}
with
{if !empty($delivery_address)}
<table style="width: 100%">
<tr>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Delivery Address' pdf='true'}</span><br />
{$delivery_address}
</td>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing Address' pdf='true'}</span><br />
{$invoice_address}
</td>
</tr>
</table>
{else}
<table style="width: 100%">
<tr>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Delivery Address' pdf='true'}</span><br />
{$invoice_address}
</td>
<td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing Address' pdf='true'}</span><br />
{$invoice_address}
</td>
</tr>
</table>
{/if}
Well I have been at this for hours now. I'm using HTML2PDF to generate an invoice. My program creates a temporary invoice without issue. The issue I'm having is once the program tries to create a PDF from the temp file I'm getting an error:
ERROR n°5
File : /home/x/public_html/office/cron/invoices/php-pdf/_class/parsingHtml.class.php
Line : 218
HTML code invalid, all tags must be closed.
Status :
Array
(
[0] => page
[1] => table
[2] => tr
[3] => td
[4] => table
[5] => tr
[6] => td
)
I understand its saying all the HTML tags have not been closed. I've validated my code many different times, many different ways and sites and all are returning valid. I had some style issues that have been fixed but I still have no luck. My html is as follows:
<!doctype html>
<html>
<head>
<title>Untitled Document</title>
<style>
<!--
body {font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
.center {text-align:center;}
.ltgray {color:#C5C5C5;}
.invoice {vertical-align:text-top;}
.gbk td {background-color:#EDEBEB; border:none; font-size:13px; padding-bottom:8px; padding-top:8px; padding-left:10px}
.btboader { border-bottom:thin dotted; border-color:#E4E2E2; padding-bottom:8px; padding-top:8px; padding-left:10px }
.ltgrayt {color:#969696;}
.center {align-content:center; font-size:12px; font-weight:bold;}
.db {border:thin dotted; background-color:#EDEBEB;}
.padded {padding-left:15px;}
.hr { border: 0; height: 1px; background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); }
-->
</style>
</head>
<body>
<table style="width: 100%">
<tr>
<td class="invoice"><h2 class="ltgray">Invoice</h2> </td>
<td style="float: right">
<table>
<tr>
<td>Date:</td> <td> 03/12/2015</td>
</tr>
<tr>
<td>Invoice #:</td> <td> 100367</td>
</tr>
<tr>
<td> Propery </td> <td> N/a </td>
</tr>
</table>
</td>
</tr>
</table>
<p></p>
<table style="width: 95%; margin: 0 auto;">
<tr>
<td style="width: 50%"><span class="ltgray">Company Information</span><br />
<strong>XXX</strong><br />XXXX<br />XXXX</td>
<td style="width: 50%"><span class="ltgray">Customer Information</span><br />
<strong>XXXX</strong><br />XXXX<br />
XXXX<br />XXXX<br />Phone: XXXX<br />Email: XXXX</td>
</tr>
</table>
<br /><p></p>
<table style="width: 100%" class="tbl">
<tr class="gbk">
<td style="width: 60%"><strong>Item</strong></td>
<td style="width: 15%"><strong>Price</strong></td>
<td style="width: 10%"><strong>Qty</strong></td>
<td style="width: 15%; margin: 0 auto;"> <strong>Total</strong> </td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Red</td>
<td style="width: 15%" class="btboader">$2.50</td>
<td style="width: 10%" class="btboader">153</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$382.50</td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Black</td>
<td style="width: 15%" class="btboader">$3.50</td>
<td style="width: 10%" class="btboader">1</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$3.50</td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Brown<br><small>Bagged mulch, price includes delivery - Total 2 1/2 pallets</small> </td>
<td style="width: 15%" class="btboader">$3.50</td>
<td style="width: 10%" class="btboader">160</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$560.00</td>
</tr>
<tr>
<td colspan="2">
<table style="width: 100%">
<tr>
<td style="width: 20%">Payment Terms:</td>
<td style="width: 80%">Due On Receipt</td>
</tr>
<tr>
<td style="width: 50%">Discount(%):</td>
<td style="width: 50%">10.0</td>
</tr>
<tr>
<td style="width: 50%">Past Due Amount:</td>
<td style="width: 50%">$0.00</td>
</tr>
</table>
</td>
<td colspan="2">
<table style="width: 100%">
<tr>
<td style="width: 50%" class="ltgrayt">Subtotal:</td>
<td style="width: 50%; float: right;">$946.00</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Tax (6.5%):</td>
<td style="width: 50%; float: right;"> $0.00</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Discount:</td>
<td style="width: 50%; float: right;"> $94.60</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Past Due:</td>
<td style="width: 50%; float: right;"><strong> $0.00 </strong></td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Total:</td>
<td style="width: 50%; float: right;"><strong> $851.40 </strong></td>
</tr>
</table>
</td>
</tr>
</table>
<br /><br />
<table class="db" style="width: 80%; margin: 0 auto;">
<tr>
<td><strong class="padded"><small>Order Notes:</small></strong><br /><p class="padded">Thank you for your business!</p>
</td>
</tr>
</table>
<hr class="hr">
<p class="center">XXXX, XXXX, XXXX - Phone: XXXX - Direct Cell: XXXX Email:XXXX<br />
Please make checks payable to: XXXX</p>
</body>
</html>
What am I missing that's causing this error? The only other thing I could think of is that HTML2PDF doesn't support something in my styling. I use HTML2PDF for another project without issue so Im not sure where I made a wrong turn.
Im using html2pdf to convert some dynamic html to pdf. My output is this.
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
set_include_path(dirname(__FILE__)."/");
require 'html2pdf/html2pdf.class.php';
$html2pdf = new HTML2PDF('P','A4','es');
ob_end_clean();
$html2pdf->WriteHTML($pruebachidoone);
$html2pdf->Output("test.pdf", 'F'); //save pdf
$html2pdf->Output("test.pdf", 'I');
but it keeps me generating the pdf like this. (this is the firts page, the other 2 are kind of the same)(in the second page the images are so large, more than in the actual page).
https://scontent-b-lax.xx.fbcdn.net/hphotos-prn2/t1.0-9/q71/s720x720/10270720_10152420268666100_7548907389881154350_n.jpg
when the page look like this
https://scontent-b-lax.xx.fbcdn.net/hphotos-frc3/t1.0-9/10395852_10152420266381100_3150074092233664051_n.jpg
im going to append the html code. this html its what "pruebachidoone" contains.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cotizacion</title>
<style type="text/css">
.top{
width: 1036px;
height:50px;
background-color:#E33FA6;
margin-bottom:0;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-color:#000;
border-width:1px;
border-style:solid;
}
#base {
HEIGHT: 1219px;
WIDTH: 200px;
background-color:#F4EAF4;
top:10px;
position:relative;
margin-top: -10px;
border-color:#000;
border-width:1px;
border-style:solid;
}
#tablageneral {
position: relative;
HEIGHT: 1209px;
WIDTH: 1017px;
border-color: #000;
border: solid;
border-width:1px;
top:5px;
}
#tablageneral1 {
position: relative;
HEIGHT: auto;
WIDTH: 900px;
max-height: 190px;
border-color: #000;
border: solid;
border-width:1px;
top:5px;
display:block;
}
.cuadrito {
max-height:183px;
display: block;
word-wrap:break-word;
}
.cuadrito2 {
max-height:96px;
display: block;
word-wrap:break-word;
}
.cuadrito3 {
max-height:100px;
display: block;
word-wrap:break-word;
}
.cuadrito4 {
max-height:101px;
display: block;
word-wrap:break-word;
}
.cuadrito5 {
max-height:66px;
display: block;
word-wrap:break-word;
}
.cuadrito6 {
max-height:256px;
display: block;
word-wrap:break-word;
}
.cuadrito7 {
max-height:176px;
display: block;
word-wrap:break-word;
}
.cuadrito8 {
max-height:230px;
display: block;
word-wrap:break-word;
}
.imagen {
position:relative;
margin:auto;
}
.texto1 {
position:relative;
top:-10px;
}
.titulos {
font-size:16px;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-weight:
}
.informacion {
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
}
.seleccion {
font-size:14px;
font-family:Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<div class="top"></div>
<div id="base">
<table id="tablageneral" cellspacing="0" cellpadding="0" rules="all" align="center" bgcolor="#ffffff">
<tr width="1016px" height="183px">
<td class="cuadrito" width="533" height="183" align="center"><img class="imagen" alt="Logo Quality" style="HEIGHT: 101px; WIDTH: 226px; position:relative;" border="0" src="http://democotiza.acesistemas.com/images/quality_cocinas_logo_chico.png" />
<p class="texto1" align="center"><font size="3"><strong>SUCURSAL</strong></font>'. $sucursal . '<br />
'.$dirsuc.' '.$numsuc.' <br />
'.$colsuc.' '.$munsuc.'<br />
<font size="2"><strong>Tel.- '.$telsuc.' </strong></font></p></td>
<td width="483" height="183"><p align="center"><strong><font size="3">PRESUPUESTO</font></strong> <strong><font size="3">No </font></strong> '. $refcot.' <br/>
<br />
<font size="3"><strong>FECHA</strong></font> <strong><font size="3">COTIZACION </font></strong> '. $fechacot.' <br />
<br />
<strong><font size="3">TIPO</font></strong> <strong><font size="3">DE</font></strong> <strong><font size="3">COTIZACION</font></strong> '. $tipocot.'</p></td>
</tr>
<tr width="1016px" height="96px">
<td class="cuadrito2" width="533" height="96"><span class="titulos" ><u>DISEÑO ESPECIAL PARA:</u> </span><br />
<span class="informacion"> '. $cte.''. $nomcliecot.' <br/>
'. $dirclicot.' <br/>
'. $colcliecot.' <br/>
'. $munclicot.' <br/>
'. $edocot.'</span></td>
<td width="483" height="96" valign="top"><span class="titulos"><u>DATOS DE CONTACTO</u></span><br />
<span class="informacion"> TELEFONO: '. $telcliecot.'<br />
CELULAR: '. $celcliecot.'<br />
E-MAIL: '. $mailcliecot.'</span></td>
</tr>
<tr width="1016px" height="100px">
<td class="cuadrito3" width="533" height="100"><span class="titulos"><u>MODELO: </u></span><span class="class""seleccion">'. $modelo.'</span><br />
<span class="informacion">Otras Opciones:</span><br />
<span class="seleccion"> VERSATIL<br />
LAMINADO PLASTICO<br />
MDF<br />
ITALIA IMPORTADO</span></td>
<td width="483" height="100" valign="top"><span class="titulos"><u>CUBIERTAS: </u></span><span class="seleccion">'. $cubierta.'</span><br />
<span class="informacion">Otras Opciones:</span><br />
<span class="seleccion"> FORMICA <br />
GRANITO <br />
SUP. SOLIDA </span></td>
</tr>
<tr width="1016px" height="101px">
<td class="cuadrito4" width="533" height="101"><span class="titulos"><u>INTERIORES:</u></span><span class="seleccion">'. $maderas.'</span><br />
<span class="informacion">Otras Opiciones:</span><br />
<span class="seleccion"> CEDRO<br />
MAPLE<br />
ENCINO<br />
NOGAL<br />
</span></td>
<td width="483" height="101" valign="top"><span class="titulos"><u>EQUIPO ADICIONAL</u></span><br />
<span class="informacion"> '. $equipo.'</span></td>
</tr>
<tr width="1016px" height="66px">
<td class="cuadrito5" width="533" height="66"><span class="titulos"><u>MEDIDAS</u></span><br />
<span class="informacion"> '. $medidas.'</span></td>
<td width="483" height="66" valign="top"><span class="titulos"><u>ACCESORIOS</u></span><br />
<span class="informacion"> '. $accesorios.'</span></td>
</tr>
<tr width="1016px" height="256px">
<td class="cuadrito6" width="533" height="256" valign="top"><span class="titulos"><u>PRECIOS</u></span><br />
<br />
<blockquote>
<span class="seleccion">MUEBLES</span>; <span class="informacion"> '. $pciomueble.' </span><br />
<br />
<span class="seleccion">CUBIERTAS</span>; <span class="informacion">'. $pciocubierta.' </span><br />
<br />
<span class="seleccion">EQUIPO</span>; <span class="informacion">'. $pcioequipo.' </span><br />
<br />
<span class="seleccion">ACCESORIOS</span>; <span class="informacion">'. $pcioaccesorios.'</span> <br />
<br />
<span class="seleccion">ADICIONALES</span>; <span class="informacion">'. $pcioadicionales.' </span><br />
<br />
<br />
<span class="seleccion">TOTAL</span>; <span class="informacion">'. $precio.'</span></blockquote>
</td>
<td width="483" height="256"><p align="center"><img alt="servcompleto" style="HEIGHT: 188px; WIDTH: 255px" border="0" src="http://democotiza.acesistemas.com/include/include2/images/servcompleto.png" width="744" height="572" /></p></td>
</tr>
<tr width="1016px" height="176px">
<td class="cuadrito7" width="533" height="176"><span class="titulos"><u>APLICA DESCUENTO POR FORMA DE PAGO</u></span><br />
<span class="seleccion">Efectivo o
Cheque
10% Desc</span><br />
<br />
<span class="seleccion">Pago con Tarjeta a 6 Meses sin
Intereses 5% Desc</span><br />
<br />
<span class="seleccion">Pago con Tarjeta a 12 Meses sin
intereses 0% Desc</span><br />
<br />
<span class="seleccion">DESCUENTO UNICAMENTE EN MUEBLES</span></td>
<td width="483" height="176" align="center"><span class="titulos">CUALQUIER DUDA NO DUDE EN CONTACTARNOS</span><br />
<span class="titulos">ESTOY PARA SERVIRLE...</span><br />
<br />
<span class="seleccion">VENDEDOR:</span> '. $vend.'
<span class="seleccion">TEL:</span> '. $telvend.'<br />
<span class="seleccion">CEL:</span> '. $celvend.' </td>
</tr>
<tr width="1016px" height="200px">
<td width="auto" height="200" colspan="2" align="center"><span class="titulos"><u>SUCURSALES</u></span><br />
<table id="tablageneral1" cellspacing="0" cellpadding="0" rules="all" align="center" bgcolor="#ffffff">
<tr>
<td width="300px" valign="top"><span class="seleccion"><u><b>QUALITY GONZALITOS</b></u> <br />
AVE.GONZALITOS No.210 COL VISTA HERMOSA<br />
MONTERREY N.L. C.P.64620<br />
TEL 83486700 83482900</span></td>
<td width="300px" valign="top"><span class="seleccion"><u><b>QUALITY LA FE</b></u> <br />
ROMULO GARZA # 101 FRACC. DEL LAGO <br />
SAN NICOLAS DE LOS GARZA N.L. C.P.66477 <br />
TEL 83219191</span></td>
<td width="300px" valign="top"><span class="seleccion"> <u><b>QUALITY MADERO</b></u> <br />
AVE MADERO No.1254 ZONA CENTRO <br />
MONTERREY N.L. C.P.64000 <br />
TEL 83726696 83754319 </span></td>
</tr>
<tr>
<td width="300px" valign="top"><span class="seleccion"><u><b>QUALITY SENDERO</b></u> <br />
AVE SENDERO # 442 LOCAL 1 Y 2 COL. NOGALERA<br />
ESCOBEDO NUEVO LEON <br />
TEL 80582280 </span></td>
<td width="300px" valign="top"><span class="seleccion"><u><b>QUALITY SUC.VICTORIA</b></u> <br />
CALLE 22 #513 ENTRE BRAVO Y ALLENDE<br />
COL CENTRO CD VICTORIA TAMPS.<br />
TEL 83431 24840 y 83431 24850</span></td>
<td width="300px" valign="top"><span class="seleccion"><u><b>QUALITY CONTRY</b></u> <br />
AVE REVOLUCION No.1206 COL CONTRY MONTERREY N.L.<br />
C.P.64845<br />
TEL 8349 5858 83496060</span></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>
I'm trying to update different rows from mysql that they filtered by some record . in this code first the user should enter two input : classnumber and level .
records that they have this fields will show in table then the user should be able to update this records information . but the problem is all of records are in one table in mysql so their id is different I mean for example the first record that match with two inputs id is 2 and then the next one is 5 and next one 6 and ....
with this kind of situation how should I change the code below ?
<form id="searchform" method="post" dir="rtl" action="">
level :<input name="level" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="level" />
classnumber :<input name="classnum" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="classnum" />
<input style="margin-top:10px; margin-left:120px; font-size: 14px; padding: 5px 14px;" type="submit" value="جستجو" name="enter" />
</form>
<?php
if(isset($_POST['enter'])){
$sql="SELECT * FROM `".$tbl_name."` where classnum='".$_REQUEST['classnum']."' and level='".$_REQUEST['level']."' ";
$result=mysql_query($sql,$link);
$count=mysql_num_rows($result);
}
?>
<div class="cleaner h30"></div>
<br>
<form name="form1" action="" method="POST">
<center>
<div>
<div align="center" width = 615>
<table class="stats" cellspacing="0" width="615" border="1">
<tr>
<th width="20" scope="col" >Id</th>
<th width="60" scope="col">Name</th>
<th width="60" scope="col">Last Name</th>
<th width="42" scope="col">Midterm</th>
<th width="54" scope="col">Class mark</th>
<th width="42" scope="col">Final Quiz</th>
<th width="54" scope="col">State</th>
<th width="54" scope="col">Details</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
$id[]=$rows['id'];
?>
<tr>
<td align="center">
<input name="id[]" type="text" id="id" value="<? echo $rows['id']; ?>" style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 10px;"></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="name[]" id="name" value= "<? echo $rows['name']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="lastname[]" id="lastname" value= "<? echo $rows['lastname']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="midmark[]" id="midmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="classmark[]" id="classmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="finalmark[]" id="finalmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="state[]" id="state" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="details[]" id="details" /></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</center>
<input style="margin-top:10px; float:right; margin-right:175px; font-size: 14px; padding: 5px 14px;" type="submit" value="ثبت" name="Submit" />
</form>
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit']))
{
for($i=0;$i<$count;$i++)
{
$sql1=mysql_query(" UPDATE `".$tbl_name."` SET midmark='".$_REQUEST['midmark'][$i]."' , classmark='".$_REQUEST['classmark'][$i]."' , finalmark='".$_REQUEST['finalmark'][$i]."' , state='".$_REQUEST['state'][$i]."' , details='".$_REQUEST['details'][$i]."' WHERE id='".$_REQUEST['id'][$i]."' "); $result1=mysql_query($sql1);
}
}
if($result1){
header("location:results.php");
}
mysql_close();
?>
The plugin works in all other pages in all browsers. In this page plugin working only in IE9 and not in FF, Chrome. In FF, Chrome the form is getting submitted with errors.
i should send my html...i am include my jquery validation but still not working?
<script src="../inc/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="../inc/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
if page is loded alert working properly... then i should click button there are nor working validation..but file should be exit...
<script type="text/javascript">
$(document).ready(function(){
alert("test");
// binds form submission and fields to the validation engine
$("#form_page").validationEngine();
});
</script>
i also send html
<form name="form_page" id="form_page" enctype="multipart/form-data" method="post" action="/1MP1/ap/manufacturer_edit.php">
<td>
<div class="error_box">
<div class="error_msg">
<img src="images/remove.png" alt=""/>
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr height="50px">
<td width="29%" style="border-bottom:1px solid #e9eaeb; border-top:1px solid #e9eaeb;" align="right"><span class="addedittitles">Manufacturer Name</span></td>
<td width="71%" style="border-bottom:1px solid #e9eaeb; border-top:1px solid #e9eaeb;"><span style="border-bottom:1px solid #e9eaeb;"><span class="faq_colomn_right">
<input name="mfgName" type="text" id="mfgName" class="validate[required,maxSize[250]]" value="" maxlength="250" style="width:85%; border:1px solid #cdcdcf; height:22px;"/>
</span>
</span></td>
</tr>
<tr>
<td style="border-bottom:1px solid #e9eaeb; margin-top:10px; margin-bottom:10px;" align="right"><span class="addedittitles" style="margin-top:10px;">Description</span></td>
<td style="border-bottom:1px solid #e9eaeb; "><span class="faq_colomn_right">
<textarea name="mfgDesc" id="mfgDesc" class="validate[required]" cols="35" style="width:572px; order:1px solid #cdcdcf; height: 200px;"> </textarea>
</span></td>
</tr>
<tr>
<td style="border-bottom:1px solid #e9eaeb; margin-top:10px; margin-bottom:10px;" align="right"><span class="addedittitles">Website Url</span></td>
<td style="border-bottom:1px solid #e9eaeb; "><span class="faq_colomn_right">
<input class="validate[required,maxSize[250]]" name="mfgWebsiteURL" id="mfgWebsiteURL" type="text" value="" maxlength="250" style="width:85%; border:1px solid #cdcdcf; height:22px;"/>
</span></td>
</tr>
<tr>
<td style="border-bottom:1px solid #e9eaeb; margin-top:10px; margin-bottom:10px;" align="right"><span class="addedittitles">Contact Name</span></td>
<td style="border-bottom:1px solid #e9eaeb; "><span class="faq_colomn_right">
<input class="validate[required,maxSize[250]]" name="mfgContactName" id="mfgContactName" type="text" value="" maxlength="250" style="width:85%; border:1px solid #cdcdcf; height:22px;"/>
</span></td>
</tr>
<tr>
<td style="border-bottom:1px solid #e9eaeb; margin-top:10px; margin-bottom:10px;" align="right"><span class="addedittitles">Phone No</span></td>
<td style="border-bottom:1px solid #e9eaeb; "><span class="faq_colomn_right">
<input class="validate[required,maxSize[250],custom[phone]]" name="mfgContactPhone" id="mfgContactPhone" type="text" value="" maxlength="100" style="width:85%; border:1px solid #cdcdcf; height:22px;"/>
</span></td>
</tr>
<tr>
<td style="border-bottom:1px solid #e9eaeb; margin-top:10px; margin-bottom:10px;" align="right"><div class="addedittitles">Email</div></td>
<td style="border-bottom:1px solid #e9eaeb; "><span class="faq_colomn_right">
<input class="validate[required,maxSize[250],custom[email]]" name="mfgContactEmail" id="mfgContactEmail" type="text" value="" maxlength="250" style="width:85%; border:1px solid #cdcdcf; height:22px;"/>
</span></td>
</tr>
<tr align="right">
<td height="40px;" align="right" colspan="4"><input name="save" type="submit" id="save" value="Save" class="button1" />
<input name="id" type="hidden" id="id" value="new">
</td>
</tr> </table>
</td>
</form>
There is a great validation plugin, called jquery validation, see here.
Remember, you should include jQuery BEFORE inclusion of other plugins.