Probleme de syntaxe
Posté : 28 oct. 2013, 12:21
Bonjour chers amis
je reviens encore pour mon application gestion des hôtels.
mon problème est je veux afficher le listes des réservations mais je n'y arrive.
j'explique: au fait j'ai 3 tables liées la table T_client, T_chambre, et T_réservation les identifiant client et chambre sont inscrits dans la table réservation après chaque validations d'une réservation et je veux afficher la liste des réservations seulement que je veux qu'à l'affichage je n'ai pas des les identifiants mais les noms et prénoms des clients et le nom des chambres.
voici mes tables:
CREATE TABLE IF NOT EXISTS `chambre` (
`id_chambre` int(11) NOT NULL AUTO_INCREMENT,
`chambre_nom` varchar(45) DEFAULT NULL,
`chambre_type` varchar(45) DEFAULT NULL,
`chambre_prix` float DEFAULT NULL,
PRIMARY KEY (`id_chambre`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
CREATE TABLE IF NOT EXISTS `client` (
`id_client` int(11) NOT NULL AUTO_INCREMENT,
`client_npcid` varchar(45) DEFAULT NULL,
`client_nom` varchar(45) DEFAULT NULL,
`client_pren` varchar(45) DEFAULT NULL,
`client_datenais` date DEFAULT NULL,
`client_nat` varchar(45) DEFAULT NULL,
`client_tel` varchar(45) DEFAULT NULL,
`client_bp` varchar(45) DEFAULT NULL,
`client_fonct` varchar(45) NOT NULL,
`client_vilprov` varchar(45) DEFAULT NULL,
`client_vilres` varchar(45) DEFAULT NULL,
`client_raissej` varchar(45) NOT NULL,
`client_employeur` varchar(45) NOT NULL,
PRIMARY KEY (`id_client`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
CREATE TABLE IF NOT EXISTS `reservation` (
`id_reserv` int(11) NOT NULL AUTO_INCREMENT,
`id_client` int(11) NOT NULL,
`id_chambre` int(11) NOT NULL,
`datedeb` date NOT NULL,
`datefin` date NOT NULL,
`nbre` int(11) NOT NULL,
`datenreg` date NOT NULL,
`prix` int(11) NOT NULL,
`montant` float NOT NULL,
PRIMARY KEY (`id_reserv`),
KEY `id_client` (`id_client`),
KEY `id_chambre` (`id_chambre`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
voila le code que j'ai écrit:
$req='SELECT * FROM reservation, chambre, client WHERE(client.id_client=reservation.id_client) and (chambre.id_chambre=reservation.id_chambre) and (id_reserv=id_reserv)';
$val=mysql_fetch_row($req);
while($val)
{
$datefin=$val['datefin'];
$datedeb=$val['datedeb'];
?>
<?php echo "$val['client_nom'] $val['client_pren']";?><br/>
<?php echo"$val['chambre_nom'] $val['chambre_type']";?><br/>
<hr/>
<p>TOTAL:<?php echo $val['montant']; ?>
l'erreur est: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\script\fiche.php
Merci d'avance
je reviens encore pour mon application gestion des hôtels.
mon problème est je veux afficher le listes des réservations mais je n'y arrive.
j'explique: au fait j'ai 3 tables liées la table T_client, T_chambre, et T_réservation les identifiant client et chambre sont inscrits dans la table réservation après chaque validations d'une réservation et je veux afficher la liste des réservations seulement que je veux qu'à l'affichage je n'ai pas des les identifiants mais les noms et prénoms des clients et le nom des chambres.
voici mes tables:
CREATE TABLE IF NOT EXISTS `chambre` (
`id_chambre` int(11) NOT NULL AUTO_INCREMENT,
`chambre_nom` varchar(45) DEFAULT NULL,
`chambre_type` varchar(45) DEFAULT NULL,
`chambre_prix` float DEFAULT NULL,
PRIMARY KEY (`id_chambre`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
CREATE TABLE IF NOT EXISTS `client` (
`id_client` int(11) NOT NULL AUTO_INCREMENT,
`client_npcid` varchar(45) DEFAULT NULL,
`client_nom` varchar(45) DEFAULT NULL,
`client_pren` varchar(45) DEFAULT NULL,
`client_datenais` date DEFAULT NULL,
`client_nat` varchar(45) DEFAULT NULL,
`client_tel` varchar(45) DEFAULT NULL,
`client_bp` varchar(45) DEFAULT NULL,
`client_fonct` varchar(45) NOT NULL,
`client_vilprov` varchar(45) DEFAULT NULL,
`client_vilres` varchar(45) DEFAULT NULL,
`client_raissej` varchar(45) NOT NULL,
`client_employeur` varchar(45) NOT NULL,
PRIMARY KEY (`id_client`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
CREATE TABLE IF NOT EXISTS `reservation` (
`id_reserv` int(11) NOT NULL AUTO_INCREMENT,
`id_client` int(11) NOT NULL,
`id_chambre` int(11) NOT NULL,
`datedeb` date NOT NULL,
`datefin` date NOT NULL,
`nbre` int(11) NOT NULL,
`datenreg` date NOT NULL,
`prix` int(11) NOT NULL,
`montant` float NOT NULL,
PRIMARY KEY (`id_reserv`),
KEY `id_client` (`id_client`),
KEY `id_chambre` (`id_chambre`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
voila le code que j'ai écrit:
$req='SELECT * FROM reservation, chambre, client WHERE(client.id_client=reservation.id_client) and (chambre.id_chambre=reservation.id_chambre) and (id_reserv=id_reserv)';
$val=mysql_fetch_row($req);
while($val)
{
$datefin=$val['datefin'];
$datedeb=$val['datedeb'];
?>
<?php echo "$val['client_nom'] $val['client_pren']";?><br/>
<?php echo"$val['chambre_nom'] $val['chambre_type']";?><br/>
<hr/>
<p>TOTAL:<?php echo $val['montant']; ?>
l'erreur est: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\script\fiche.php
Merci d'avance