Professional Documents
Culture Documents
Modifica el codi solució de l’exercici 47 punt 4 el qual t’adjunto aquí de forma que ara en processar-se el
formulari es mostri amb el següent format:
Indicacions i requeriments:
1. De moment l’únic que has de modificar és la presentació. Pel que respecta al que guardem en un
arxiu no cal que en aquest punt facis res.
2. A continuació et poso el codi de partida per a realizar la pràctica:
Arxiu index.php
<?php
if(!isset($_GET['tireqty'])){
?>
//Events en jQuery
$(document).ready(function(){
});
function valida(){
//Primer que res recullo el valor dels tres camps usant AJAX
var u=jQuery('input:eq(0)').attr('value');
var dos=jQuery('input:eq(1)').attr('value');
var tres=jQuery('input:eq(2)').attr('value');
function procesa(){
//Primer que res recullo el valor dels tres camps usant AJAX
var atr1 = jQuery('input:eq(0)').attr('value');
var atr2 = jQuery('input:eq(1)').attr('value');
var atr3 = jQuery('input:eq(2)').attr('value');
//I miro si algun dels tres és null ja que els incorrectes els haure posat a null
if ((atr1 == '') || (atr2 == '') ||(atr3 == '')){
//Vaig a fer aquí la creació del paràgraf per jQuery primer recollint el contingut del paragraf
alert('cas dolent');
var cont = jQuery('form').html();
document.location.href=direccio;
}
</script>
<style type="text/css">
body {
padding: 40px;
}
form {
border: 1px solid;
padding: 15px;
width: 320px;
background-color: #ccffcc;
}
/*La regla per a posar en bermell el tema de l'important'*/
.imp{
color: red;
text-decoration: underline;
}
.groc{
background-color: greenyellow;
}
</style>
<title>Primer PHP</title>
</head>
<body>
<form>
<table border="0">
<tr bgcolor="red">
<td width="150">Item</td>
<td width="150">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Spark plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>How did you find us?</td>
<td align="center">
<select name="find">
<option value="a">I am a regular costumer</option>
<option value="b">Phone directory</option>
<option value="c">Tv advertising</option>
<option value="d">Others</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left"><input type="button" value="submitorder"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else {
?>
<style type="text/css">
</style>
<title>Comanda processada</title>
</head>
<body>
<?php
echo '<p>Comanda processada amb PHP en data '.date('H:i, jS F').'</p>';
$tireqty=$_GET['tireqty'];
$oilqty=$_GET['oilqty'];
$sparkqty=$_GET['sparkqty'];
$find=$_GET['find'];
$total=$tireqty*2+$oilqty*5+$sparkqty*3;
switch ($find)
{
case 'a': echo '<p>Has indicat que ets un client habitual</p>';
echo '<p>Preu amb descompte: <em>' . $total*(0.7). '</em></p>';
break;
case 'b': echo '<p>>Has indicat que ens has trobat a la guia telefonica</p>';
echo '<p>Preu amb descompte: <em>' . $total*(0.8). '</em></p>';
break;
case 'c': echo "<p>Has indicat que ens has trobat gracies a l'anunci de TV</p>";
echo '<p>Preu amb descompte: <em>' . $total*(0.9). '</em></p>';
break;
case 'd': echo '<p>Has indicat que ens has trobat per altres causes</p>';
echo '<p>Preu amb descompte: <em>' . $total*(0.95). '</em></p>';
break;
}
$comanda=$tireqty."\r\n".$oilqty."\r\n".$sparkqty."\r\n".$find."\r\n".$total."\r\n";
echo $comanda;
fwrite($fp, $comanda);
flock($fp,LOCK_UN);
fclose($fp);
}
?>
</body>
</html>
<?php
}
?>
Esnombre.php
<?php
$tireqty=$_POST['tireqty'];
$oilqty=$_POST['oilqty'];
$sparkqty=$_POST['sparkqty'];
$sor=0;
?>
?>
Resposta :
<?php
if(!isset($_GET['tireqty'])){
?>
//Events en jQuery
$(document).ready(function(){
});
function valida(){
//Primer que res recullo el valor dels tres camps usant AJAX
var u=jQuery('input:eq(0)').attr('value');
var dos=jQuery('input:eq(1)').attr('value');
var tres=jQuery('input:eq(2)').attr('value');
function procesa(){
//Primer que res recullo el valor dels tres camps usant AJAX
var atr1 = jQuery('input:eq(0)').attr('value');
var atr2 = jQuery('input:eq(1)').attr('value');
var atr3 = jQuery('input:eq(2)').attr('value');
//I miro si algun dels tres és null ja que els incorrectes els haure posat a null
if ((atr1 == '') || (atr2 == '') ||(atr3 == '')){
//Vaig a fer aquí la creació del paràgraf per jQuery primer recollint el contingut del paragraf
alert('cas dolent');
var cont = jQuery('form').html();
document.location.href=direccio;
}
</script>
<style type="text/css">
body {
padding: 40px;
}
form {
border: 1px solid;
padding: 15px;
width: 320px;
background-color: #ccffcc;
}
/*La regla per a posar en bermell el tema de l'important'*/
.imp{
color: red;
text-decoration: underline;
}
.groc{
background-color: greenyellow;
}
</style>
<title>Primer PHP</title>
</head>
<body>
<form>
<table border="0">
<tr bgcolor="red">
<td width="150">Item</td>
<td width="150">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Spark plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>How did you find us?</td>
<td align="center">
<select name="find">
<option value="a">I am a regular costumer</option>
<option value="b">Phone directory</option>
<option value="c">Tv advertising</option>
<option value="d">Others</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left"><input type="button" value="submitorder"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else {
?>
border-collapse: collapse;
}
thead{
</style>
<title>Comanda processada</title>
</head>
<body>
<?php
echo '<p>Comanda processada amb PHP en data '.date('H:i, jS F').'</p>';
$tireqty=$_GET['tireqty'];
$oilqty=$_GET['oilqty'];
$sparkqty=$_GET['sparkqty'];
$find=$_GET['find'];
$total=$tireqty*2+$oilqty*5+$sparkqty*3;
echo '<td>';
echo $oilqty;
echo '</td>';
switch ($find)
{
case 'a': echo '<td>Has indicat que ets un client habitual</td>';
echo '<td>'. $total*(0.7). '</td>';
break;
case 'b': echo '<td>Has indicat que ens has trobat a la guia telefonica</td>';
echo '<td>'. $total*(0.8). '</td>';
break;
case 'c': echo "<td>Has indicat que ens has trobat gracies a l'anunci de TV</td>";
echo '<td>' . $total*(0.9). '</td>';
break;
case 'd': echo '<td>Has indicat que ens has trobat per altres causes</td>';
echo '<td>' . $total*(0.95). '</td>';
break;
}
//la data
echo '</tr></tbody></table>';
$comanda=$tireqty."\r\n".$oilqty."\r\n".$sparkqty."\r\n".$find."\r\n".$total."\r\n";
echo $comanda;
fwrite($fp, $comanda);
flock($fp,LOCK_UN);
fclose($fp);
}
?>
</body>
</html>
<?php
}
?>
Exercici 2.
Modifica el codi solució de l’exercici anterior de forma que ara el que aconsegueixis sigui el següent:
Indicacions i requeriments:
1. Fíxa-t’hi que a part de mostrar la darrera comanda introduïda des del formulari ens apareixen en
forma de resum totes les que el client ha emmagatzemat en l’arxiu de text.
Resposta :
<?php
if(!isset($_GET['tireqty'])){
?>
//Events en jQuery
$(document).ready(function(){
});
function valida(){
//Primer que res recullo el valor dels tres camps usant AJAX
var u=jQuery('input:eq(0)').attr('value');
var dos=jQuery('input:eq(1)').attr('value');
var tres=jQuery('input:eq(2)').attr('value');
function procesa(){
//Primer que res recullo el valor dels tres camps usant AJAX
var atr1 = jQuery('input:eq(0)').attr('value');
var atr2 = jQuery('input:eq(1)').attr('value');
var atr3 = jQuery('input:eq(2)').attr('value');
//I miro si algun dels tres és null ja que els incorrectes els haure posat a null
if ((atr1 == '') || (atr2 == '') ||(atr3 == '')){
//Vaig a fer aquí la creació del paràgraf per jQuery primer recollint el contingut del paragraf
alert('cas dolent');
var cont = jQuery('form').html();
document.location.href=direccio;
}
</script>
<style type="text/css">
body {
padding: 40px;
}
form {
border: 1px solid;
padding: 15px;
width: 320px;
background-color: #ccffcc;
}
/*La regla per a posar en bermell el tema de l'important'*/
.imp{
color: red;
text-decoration: underline;
}
.groc{
background-color: greenyellow;
}
</style>
<title>Primer PHP</title>
</head>
<body>
<form>
<table border="0">
<tr bgcolor="red">
<td width="150">Item</td>
<td width="150">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Spark plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>How did you find us?</td>
<td align="center">
<select name="find">
<option value="a">I am a regular costumer</option>
<option value="b">Phone directory</option>
<option value="c">Tv advertising</option>
<option value="d">Others</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left"><input type="button" value="submitorder"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else {
?>
<style type="text/css">
table{
border: 2px solid;
border-collapse: collapse;
}
thead{
</style>
<title>Comanda processada</title>
</head>
<body>
<?php
echo '<p>Comanda processada amb PHP en data '.date('H:i, jS F').'</p>';
$tireqty=$_GET['tireqty'];
$oilqty=$_GET['oilqty'];
$sparkqty=$_GET['sparkqty'];
$find=$_GET['find'];
$total=$tireqty*2+$oilqty*5+$sparkqty*3;
switch ($find)
{
case 'a': echo '<td>Has indicat que ets un client habitual</td>';
$totalD = $total*(0.7);
break;
case 'b': echo '<td>Has indicat que ens has trobat a la guia telefonica</td>';
$totalD = $total*(0.8);
break;
case 'c': echo "<td>Has indicat que ens has trobat gracies a l'anunci de TV</td>";
$totalD = $total*(0.9);
break;
case 'd': echo '<td>Has indicat que ens has trobat per altres causes</td>';
$totalD = $total*(0.95);
break;
}
//la data
echo '</tr></tbody></table>';
fwrite($fp, $comanda);
flock($fp,LOCK_EX);
fclose($fp);
}
?>
if(!$fp){
echo '<p>No he pogut emmagatzemar el contingut de la comanda. Torna a introduir-la</p>';
}
else {
//En cas que hagi pogut obrir bloquejo
flock($fp,LOCK_EX);
echo '<td>';
echo $tireqty;
echo '</td>';
echo '<td>';
echo $oilqty;
echo '</td>';
flock($fp,LOCK_EX);
fclose($fp);
}
echo '</tr></tbody></table>';
?>
</body>
</html>
<?php
}
?>
Exercici 3.
Modifica el codi solució de l’exercici 2 de forma que ara el que se’t mostri sigui el següent:
Indicacions i requeriments:
1. Fíxa-t’hi que ara ha aparegut una nova columna en la taula resum en la que podem ticar no el
checkbox.
2. En cas d’estar ticat un checkbox i que es cliqui en el botó esborra ticats, s’han d’esborrar les
comandes ticades de l’arxiu order.txt. Podem ticar varies comandes si és que en volem esborrar vàries.
3. La forma de mirar en jQuery si un checkbox està ticat és la següent: $(elcheckbox).is(':checked')
4. De moment nomès cal que implementis l’esborrat en l’arxiu “font” order.txt. En l’exercici següent a
més a més el millorarem de forma que a part d’esborrar-se deixaran d’aparèixer en la taula.
Resposta :
INDEX.PHP
<?php
if(!isset($_GET['tireqty'])){
?>
//Events en jQuery
$(document).ready(function(){
});
function valida(){
//Primer que res recullo el valor dels tres camps usant AJAX
var u=jQuery('input:eq(0)').attr('value');
var dos=jQuery('input:eq(1)').attr('value');
var tres=jQuery('input:eq(2)').attr('value');
//Si un dels tres no és un nombre el posare a '' i a més el poso groc
//En cas siguin nombres els deixo en blanc
if(!jQuery.isNumeric(u)){
jQuery('input:eq(0)').attr('value','');
jQuery('input:eq(0)').attr('class','groc');
} else {
jQuery('input:eq(0)').attr('class','none');
}
if(!jQuery.isNumeric(dos)){
jQuery('input:eq(1)').attr('value','');
jQuery('input:eq(1)').attr('class','groc');
} else {
jQuery('input:eq(1)').attr('class','none');
}
if(!jQuery.isNumeric(tres)){
jQuery('input:eq(2)').attr('value','');
jQuery('input:eq(2)').attr('class','groc');
} else {
jQuery('input:eq(2)').attr('class','none');
}
function procesa(){
//Primer que res recullo el valor dels tres camps usant AJAX
var atr1 = jQuery('input:eq(0)').attr('value');
var atr2 = jQuery('input:eq(1)').attr('value');
var atr3 = jQuery('input:eq(2)').attr('value');
//I miro si algun dels tres és null ja que els incorrectes els haure posat a null
if ((atr1 == '') || (atr2 == '') ||(atr3 == '')){
//Vaig a fer aquí la creació del paràgraf per jQuery primer recollint el contingut del paragraf
alert('cas dolent');
var cont = jQuery('form').html();
document.location.href=direccio;
}
</script>
<style type="text/css">
body {
padding: 40px;
}
form {
border: 1px solid;
padding: 15px;
width: 320px;
background-color: #ccffcc;
}
/*La regla per a posar en bermell el tema de l'important'*/
.imp{
color: red;
text-decoration: underline;
}
.groc{
background-color: greenyellow;
}
</style>
<title>Primer PHP</title>
</head>
<body>
<form>
<table border="0">
<tr bgcolor="red">
<td width="150">Item</td>
<td width="150">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Spark plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>How did you find us?</td>
<td align="center">
<select name="find">
<option value="a">I am a regular costumer</option>
<option value="b">Phone directory</option>
<option value="c">Tv advertising</option>
<option value="d">Others</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left"><input type="button" value="submitorder"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else {
?>
$(document).ready(function(){
jQuery('input:last').click(function(){
//Miro quins són els que estan ticats
//i els posaré en un arrau
var arr = new Array();
var c=0;
var n = jQuery('input').length;
for(var i=0;i<n;i++){
if(jQuery('input:eq('+i+')').is(':checked')){
//Vaig posant a dins d'un array les posicions ticades'
alert("ticat: "+i+" poscion array: "+c);
arr[c]=i;
c=c+1;
}else{
alert("no ticat: "+i);}
}
//Nombre de "entrades"
n=n-1;
for(z=arr.length;z>0;z--){
var pos=arr[z-1];
alert("posició extreta de l'array: "+(z-1)+" amb volta a esborrar pos: "+pos);
alert("Nombre de vegades que faré AJAX: "+na);
alert("Nombre de voltes a larxiu nombre: "+n);
$.ajax({
type: 'POST',
url: 'http://localhost/P54/esborra.php',
dataType: 'html',
data: {
nombre: n,
posicio: pos
},
success: function(suc) {
alert('el retornat: '+suc);
},
error: function() {alert('An error occurred!');}
});
//Una menys
n=n-1;
}
//
});
});
</script>
<style type="text/css">
table{
border: 2px solid;
border-collapse: collapse;
}
thead{
</style>
<title>Comanda processada</title>
</head>
<body>
<?php
echo '<p>Comanda processada amb PHP en data '.date('H:i, jS F').'</p>';
$tireqty=$_GET['tireqty'];
$oilqty=$_GET['oilqty'];
$sparkqty=$_GET['sparkqty'];
$find=$_GET['find'];
$total=$tireqty*2+$oilqty*5+$sparkqty*3;
echo '<td>';
echo $oilqty;
echo '</td>';
switch ($find)
{
case 'a': echo '<td>Has indicat que ets un client habitual</td>';
$totalD = $total*(0.7);
break;
case 'b': echo '<td>Has indicat que ens has trobat a la guia telefonica</td>';
$totalD = $total*(0.8);
break;
case 'c': echo "<td>Has indicat que ens has trobat gracies a l'anunci de TV</td>";
$totalD = $total*(0.9);
break;
case 'd': echo '<td>Has indicat que ens has trobat per altres causes</td>';
$totalD = $total*(0.95);
break;
}
//la data
echo '</tr></tbody></table>';
fwrite($fp, $comanda);
flock($fp,LOCK_EX);
fclose($fp);
}
?>
if(!$fp){
echo '<p>No he pogut emmagatzemar el contingut de la comanda. Torna a introduir-la</p>';
}
else {
//En cas que hagi pogut obrir bloquejo
flock($fp,LOCK_EX);
echo '<td>';
echo $tireqty;
echo '</td>';
echo '<td>';
echo $oilqty;
echo '</td>';
//Incremento $i
$i=$i+1;
}
flock($fp,LOCK_EX);
fclose($fp);
}
echo '</tr></tbody></table>';
?>
</body>
</html>
<?php
}
?>
ESBORRA.PHP
<?php
$pos=$_POST['posicio'];
$fp = fopen("C:\wamp\www\P54\order.txt",'r');
$pos=$pos+1;
if(!$fp){
echo '<p>No he pogut. Torna a introduir-la</p>';
}
else {
//En cas que hagi pogut obrir bloquejo
flock($fp,LOCK_EX);
//Vaig extraient-los de 7 en 7
while(!feof($fp) && $nombre>=$volta){
if($volta != $pos){
$con=$con.fgets($fp,1024);
$con=$con.fgets($fp,1024);
$con=$con.fgets($fp,1024);
$con=$con.fgets($fp,1024);
//Al tanto que aquí em cal la fgetc!!!!!!!!!!
$con=$con.fgetc($fp);
//Per la data faig dos fgets ja que amb el primer el que aconsegueixo es arribar fins a final de línia
$con=$con.fgets($fp,1024);
$con=$con.fgets($fp,1024);
$con=$con.fgets($fp,1024);
}
if($volta == $pos){
$kk=$kk.fgets($fp,1024);
$kk=$kk.fgets($fp,1024);
$kk=$kk.fgets($fp,1024);
$kk=$kk.fgets($fp,1024);
//Al tanto que aquí em cal la fgetc!!!!!!!!!!
$kk=$kk.fgetc($fp);
//Per la data faig dos fgets ja que amb el primer el que aconsegueixo es arribar fins a final de línia
$kk=$kk.fgets($fp,1024);
$kk=$kk.fgets($fp,1024);
$kk=$kk.fgets($fp,1024);
}
$volta=$volta+1;
}
flock($fp,LOCK_UN);
fclose($fp);
}
$fq = fopen("C:\wamp\www\P54\order.txt",'w+');
if(!$fq){
echo '<p>No he pogut emmagatzemar el contingut de la comanda. Torna a introduir-la</p>';
}
else {
//En cas que hagi pogut obrir bloquejo
flock($fq,LOCK_EX);
fwrite($fq, $con);
flock($fq,LOCK_UN);
fclose($fq);
}
echo 'OK';
?>
Exercici 4.
Modifica el codi solució de l’exercici 3 de forma que ara el que se’t mostri sigui el següent:
Tico el primer i el tercer:
I com seria desitjable a part d’esborrar-se de l’arxiu order.txt desapareixen de la taula tal com pots
veure:
Resposta :
<?php
if(!isset($_GET['tireqty'])){
?>
//Events en jQuery
$(document).ready(function(){
});
function valida(){
//Primer que res recullo el valor dels tres camps usant AJAX
var u=jQuery('input:eq(0)').attr('value');
var dos=jQuery('input:eq(1)').attr('value');
var tres=jQuery('input:eq(2)').attr('value');
function procesa(){
//Primer que res recullo el valor dels tres camps usant AJAX
var atr1 = jQuery('input:eq(0)').attr('value');
var atr2 = jQuery('input:eq(1)').attr('value');
var atr3 = jQuery('input:eq(2)').attr('value');
//I miro si algun dels tres és null ja que els incorrectes els haure posat a null
if ((atr1 == '') || (atr2 == '') ||(atr3 == '')){
//Vaig a fer aquí la creació del paràgraf per jQuery primer recollint el contingut del paragraf
alert('cas dolent');
var cont = jQuery('form').html();
document.location.href=direccio;
}
</script>
<style type="text/css">
body {
padding: 40px;
}
form {
border: 1px solid;
padding: 15px;
width: 320px;
background-color: #ccffcc;
}
/*La regla per a posar en bermell el tema de l'important'*/
.imp{
color: red;
text-decoration: underline;
}
.groc{
background-color: greenyellow;
}
</style>
<title>Primer PHP</title>
</head>
<body>
<form>
<table border="0">
<tr bgcolor="red">
<td width="150">Item</td>
<td width="150">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>Spark plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"/></td>
</tr>
<tr>
<td>How did you find us?</td>
<td align="center">
<select name="find">
<option value="a">I am a regular costumer</option>
<option value="b">Phone directory</option>
<option value="c">Tv advertising</option>
<option value="d">Others</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left"><input type="button" value="submitorder"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else {
?>
$(document).ready(function(){
jQuery('input:last').click(function(){
//Miro quins són els que estan ticats
//i els posaré en un arrau
var arr = new Array();
var c=0;
var n = jQuery('input').length;
for(var i=0;i<n;i++){
if(jQuery('input:eq('+i+')').is(':checked')){
//Vaig posant a dins d'un array les posicions ticades'
alert("ticat: "+i+" poscion array: "+c);
arr[c]=i;
c=c+1;
}else{
alert("no ticat: "+i);}
}
//Nombre de "entrades"
n=n-1;
for(z=arr.length;z>0;z--){
var pos=arr[z-1];
//
});
});
</script>
<style type="text/css">
table{
border: 2px solid;
border-collapse: collapse;
}
thead{
</style>
<title>Comanda processada</title>
</head>
<body>
<?php
echo '<p>Comanda processada amb PHP en data '.date('H:i, jS F').'</p>';
$tireqty=$_GET['tireqty'];
$oilqty=$_GET['oilqty'];
$sparkqty=$_GET['sparkqty'];
$find=$_GET['find'];
$total=$tireqty*2+$oilqty*5+$sparkqty*3;
echo '<td>';
echo $oilqty;
echo '</td>';
switch ($find)
{
case 'a': echo '<td>Has indicat que ets un client habitual</td>';
$totalD = $total*(0.7);
break;
case 'b': echo '<td>Has indicat que ens has trobat a la guia telefonica</td>';
$totalD = $total*(0.8);
break;
case 'c': echo "<td>Has indicat que ens has trobat gracies a l'anunci de TV</td>";
$totalD = $total*(0.9);
break;
case 'd': echo '<td>Has indicat que ens has trobat per altres causes</td>';
$totalD = $total*(0.95);
break;
}
//la data
echo '</tr></tbody></table>';
fwrite($fp, $comanda);
flock($fp,LOCK_EX);
fclose($fp);
}
?>
echo '<td>';
echo $tireqty;
echo '</td>';
echo '<td>';
echo $oilqty;
echo '</td>';
//Incremento $i
$i=$i+1;
echo '</tr></tbody></table>';
?>
</body>
</html>
<?php
}
?>