This topic is locked

To control Add_page

10/21/2008 3:18:57 AM
PHPRunner General questions
M
maxcolo author

Good morning,

I have two table:

table "reservation"

id_reserv | data | id_position | coperti |

1 12/10/08 1 5

2 12/10/08 2 15

3 14/10/08 1 12
second table "position"
id_position | position | total_seat

1 garden 100

2 inside 50
For to prevent in reservation_add.php in event Before Add che the Sum group by data, by position is > for the total set in the position. IF and ELSE Message.
What is the demo code for to prevent this situation.

Grazie in advance

J
Jane 10/22/2008

answered in your personal email.

M
maxcolo author 10/22/2008

Hi Jane,

Any email has not arrived

Thank's

J
Jane 10/23/2008

Massimo,
here is a sample code:

global $dal;

//select sum of coperti

$str = "select sum(coperti) as sum_coperti from reservation where data='".$values["data"]."' and id_position=".$values["id_position"];

$rs = CustomQuery($str);

$data = db_fetch_array($rs);
//select total seats

$rs2 = $dal->position->Query("id_position=".$values["id_position"],"");

$data2 = db_fetch_array($rs2);
if ($data["sum_coperti"]+$values["coperti"]<$data2["total_seat"])

return true;

else

return false;

M
maxcolo author 10/24/2008

I have corrected some things and control finally works.

Thanks
[codebox]global $dal;

//select sum of coperti

$str = "select sum(coperti) as sum_coperti from prenotazioni where data='".$values["data"]."' and id_posto=".$values["id_posto"];

$rs = CustomQuery($str);

$data = db_fetch_array($rs);
//select total seats

$rs2 = $dal->posti->Query("id_posto=".$values["id_posto"],"");

$data2 = db_fetch_array($rs2);
if ($data["sum_coperti"]+$values["coperti"]>$data2["posti_totali"])

{

echo "Field name already exist";

return false;

}

else

{

return true;

} [/codebox]
How do I do to center this variable?
[codebox]echo ($data2["posti_totali"]);[/codebox]

J
Jane 10/24/2008

Here is a sample:

echo "<p align=center>".$data2["posti_totali"]."</p>";

M
maxcolo author 10/25/2008

Hi Jane,

You are great, I thank a lot you for the patience that you have had.

This forum of support is really exceptional

Best Regards