par
wuub » 07 juil. 2006, 10:44
Hello et merci de ta reponse !
Je ne me suis pas découragé ^^
Du coup je suis parvenu à faire cela !
Je ne parviens ceci dit pas à faire ensorte que l'utilisateur puisse faire un upload du fichier et que celui ci soit mis dans la valeur de loc_image.
Autre chose idiote, je ne sais pas comment vérifier que les champs sont bien remplis ...
C'est pas grand chose considerant que je viens de m'y mettre seulement et que je n'y connais pas grand chose...
J'ai plus de cheveux a force de me les arracher ^^
Code : Tout sélectionner
CREATE TABLE `locations` (
`loc_id` int(11) NOT NULL auto_increment,
`loc_ref` varchar(10) NOT NULL default '0',
`loc_type` varchar(50) NOT NULL default '',
`loc_surface` tinyint(4) NOT NULL default '0',
`loc_loggia` varchar(50) default NULL,
`loc_loyer` smallint(4) NOT NULL default '0',
`loc_charges` int(5) NOT NULL default '0',
`loc_frais` smallint(10) NOT NULL default '0',
`loc_lieu` varchar(128) NOT NULL default '',
`loc_dispo` date NOT NULL default '0000-00-00',
`loc_image` varchar(100) NOT NULL default '',
`loc_details` text NOT NULL,
PRIMARY KEY (`loc_id`),
KEY `loc_id` (`loc_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Et le code
Code : Tout sélectionner
<?php
require_once 'secure/dbconnect.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
body, table {
background-color: #000000;
color: #FFFFFF;
font: normal normal 12px arial;
}
fieldset {
padding:5px;
}
.white {
font: normal bold 12px arial;
color:white;
}
.red {
font: normal bold 12px arial;
color:red;
}
INPUT.button {
cursor:hand;
font:normal bold 11px arial;
color:#FFFFFF;
border:1;
border-style:solid;
border-color:#F24343;
background-color:gray;
}
INPUT.text {
font:normal bold 12px arial;
color:#000000;
border:1;
border-style:solid;
border-color:#c0c0c0;
background-color:white;
width:200;
}
.frame {
border-collapse: collapse;
border-left: 1px solid #000000;
border-right-color: #000000;
border-right-style: solid;
border-right-width: 1px;
border-top: 1px solid #FFFFFF;
border-bottom-style: solid;
border-bottom-width: 0px;
border-bottom-color: #FFFFFF;
}
</style>
</head>
<body bgcolor=black text=white>
<table cellpadding=0 cellspacing=0 width=700 height=40 border=1 align=center class=frame>
<tr>
<td align=center bgcolor=#660000><b>Console d'administration</b></td>
</tr>
</table>
<table cellpadding=0 cellspacing=0 width=700 height=40 border=1 align=center class=frame>
<tr>
<td bgcolor=#000000>
<?
if(isset($_POST['send'])) {
if($_POST['send'] == 'new') {
$sql =
"INSERT INTO locations
(
loc_ref
,loc_type
,loc_surface
,loc_loggia
,loc_loyer
,loc_charges
,loc_frais
,loc_lieu
,loc_dispo
,loc_image
,loc_details
)
VALUES
(
'".$_POST['loc_ref']."'
,'".$_POST['loc_type']."'
,'".$_POST['loc_surface']."'
,'".$_POST['loc_loggia']."'
,'".$_POST['loc_loyer']."'
,'".$_POST['loc_charges']."'
,'".$_POST['loc_frais']."'
,'".$_POST['loc_lieu']."'
,'".$_POST['loc_dispo']."'
,'".$_POST['loc_image']."'
,'".$_POST['loc_details']."'
)";
}
elseif($_POST['send'] == 'update') {
$sql =
' UPDATE locations SET
loc_ref = "' .$_POST['loc_ref'].'"
, loc_type = "' .$_POST['loc_type'].'"
, loc_surface = "' .$_POST['loc_surface'].'"
, loc_loggia = "' .$_POST['loc_loggia'].'"
, loc_loyer = "' .$_POST['loc_loyer'].'"
, loc_charges = "' .$_POST['loc_charges'].'"
, loc_frais = "' .$_POST['loc_frais'].'"
, loc_lieu = "' .$_POST['loc_lieu'].'"
, loc_dispo = "' .$_POST['loc_dispo'].'"
, loc_image = "' .$_POST['loc_image'].'"
, loc_details = "' .$_POST['loc_details'].'"
WHERE loc_id = "' .$_POST['loc_id'].'"';
}
mysql_query($sql,$db_link) or die(mysql_error());
}
if(isset($_GET['delete']) and is_numeric($_GET['delete'])) {
mysql_query("DELETE FROM locations WHERE loc_id = \"".$_GET['delete']."\"",$db_link);
header("location: loc_admin.php");
}
if(isset($_GET['edit']) and is_numeric($_GET['edit'])) {
$Id = $_GET['edit'] ;
$sql = 'SELECT * FROM locations WHERE loc_id = "'.$Id.'" LIMIT 1' ;
$rc = mysql_query($sql,$db_link);
while($loc_data = mysql_fetch_array($rc)) {
// Modification d'une location
print '
<fieldset>
<legend>Modification d\'une location référence : '.$loc_data['loc_ref'].'</legend>
<form action="loc_admin.php" method="post" name="loc_edit">
<table>
<tr><td width=100>Référence </td><td> « <input class="text" type="text" name="loc_ref" size="10" value="'.htmlentities($loc_data['loc_ref']).'"> » Code de référence correspondant à votre logiciel de gestion</td></tr>
<tr><td>Localisation </td><td> « <input class="text" type="text" name="loc_lieu" size="10" value="'.htmlentities($loc_data['loc_lieu']).'"> » Emplacement géographique de la location</td></tr>
<tr><td>Type </td><td> « <input class="text" type="text" name="loc_type" size="10" value="'.htmlentities($loc_data['loc_type']).'"> » Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
<tr><td>Surface </td><td> « <input class="text" type="text" name="loc_surface"size="10" value="'.htmlentities($loc_data['loc_surface']).'"> » Surface habitable de la location en M²</td></tr>
<tr><td>Loggia/Terrasse </td><td> « <input class="text" type="text" name="loc_loggia" size="10" value="'.htmlentities($loc_data['loc_loggia']).'"> » Informations sur les loggias et terrasses</td></tr>
<tr><td>Loyer </td><td> « <input class="text" type="text" name="loc_loyer" size="10" value="'.htmlentities($loc_data['loc_loyer']).'"> » Loyer mensuel hors charges en euros</td></tr>
<tr><td>Charges </td><td> « <input class="text" type="text" name="loc_charges"size="10" value="'.htmlentities($loc_data['loc_charges']).'"> » Charges mensuelles en euros</td></tr>
<tr><td>Frais d\'agence </td><td> « <input class="text" type="text" name="loc_frais" size="10" value="'.htmlentities($loc_data['loc_frais']).'"> » Frais d\'agence en euros</td></tr>
<tr><td>Disponiblité </td><td> « <input class="text" type="text" name="loc_dispo" size="10" value="'.htmlentities($loc_data['loc_dispo']).'"> » Date de disposiniblité au format AAAA/MM/JJ</td></tr>
<tr><td>Details </td><td> « <input class="text" type="text" name="loc_details"size="10" value="'.htmlentities($loc_data['loc_details']).'"> » Commentaires sur l\'offre (160 caractères)</td></tr>
<tr><td>Image </td><td> « <input class="text" type="text" name="loc_image" size="10" value="'.htmlentities($loc_data['loc_image']).'"> » Photo illustrative de l\'offre</td></tr>
<tr>
<td><input class="button" type="reset" value="Annuler" onclick="javascript:history.go(-1)"></td>
<td><input class="button" type="submit" value="Valider"></td>
</tr>
<tr>
<td><input type="hidden" name="loc_id" value="'.$_GET['edit'].'"></td>
<td><input type="hidden" name="send" value="update"></td>
</tr>
</table>
</fieldset>
</form>
';
}
}
else {
//Ajout des locations
print '
<fieldset>
<legend>Ajoût d\'une location </legend>
<form action="loc_admin.php" method="post" name="loc_add">
<i>* Remplissez les champs de votre choix puis cliquer sur "Valider"</i>
<table>
<tr><td width=100>Référence </td><td> « <input class="text" type="text" name="loc_ref" size="10"> » Code de référence correspondant à votre logiciel de gestion</td></tr>
<tr><td>Localisation </td><td> « <input class="text" type="text" name="loc_lieu" size="10"> » Emplacement géographique de la location</td></tr>
<tr><td>Type </td><td> « <input class="text" type="text" name="loc_type" size="10"> » Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
<tr><td>Surface </td><td> « <input class="text" type="text" name="loc_surface" size="10"> » Surface habitable de la location en M²</td></tr>
<tr><td>Loggia </td><td> « <input class="text" type="text" name="loc_loggia" size="10"> » Informations sur les loggias et terrasses</td></tr>
<tr><td>Loyer </td><td> « <input class="text" type="text" name="loc_loyer" size="10"> » Loyer mensuel hors charges en euros</td></tr>
<tr><td>Charges </td><td> « <input class="text" type="text" name="loc_charges" size="10"> » Charges mensuelles en euros</td></tr>
<tr><td>Frais d\'agence </td><td> « <input class="text" type="text" name="loc_frais" size="10"> » Frais d\'agence en euros</td></tr>
<tr><td>Disponibilité </td><td> « <input class="text" type="text" name="loc_dispo" size="10"> » Date de disposiniblité au format AAAA/MM/JJ</td></tr>
<tr><td>Description </td><td> « <input class="text" type="text" name="loc_details" size="10"> » Commentaires sur l\'offre (160 caractères)</td></tr>
<tr><td>Image </td><td> « <input class="text" type="text" name="loc_image" size="10"> » Photo illustrative de l\'offre</td></tr>
<tr>
<td><input class="button" type="reset" value="Effacer"></td>
<td><input class="button" type="submit" value="Valider"></td>
</tr>
</table>
</fieldset>
<input type="hidden" name="send" value="new">
</form>
';
//Gestion des locations
print '<hr><fieldset><legend>Gestion des locations </legend>';
$sql = 'SELECT * FROM locations ORDER BY loc_id DESC' ;
$rc = mysql_query($sql,$db_link);
while($loc_data = mysql_fetch_array($rc)) {
print
'<table><tr><td width=350>'
.'<li>Référence : ' .$loc_data['loc_ref']
.'<li>Localisation : ' .$loc_data['loc_lieu']
.'<li>Type : ' .$loc_data['loc_type']
.'<li>Surface : ' .$loc_data['loc_surface'] . ' m²'
.'<li>Loggia / Terrasse : ' .$loc_data['loc_loggia']
.'<li>Loyer : ' .$loc_data['loc_loyer'] . ' € + '
.$loc_data['loc_charges'] .' € de charges'
.'<li>Frais d\'agence : ' .$loc_data['loc_frais'] . ' €'
.'<li>Disponibilité : ' .$loc_data['loc_dispo']
.'<li>Description : ' .$loc_data['loc_details']
.'<li>Image : ' .$loc_data['loc_image']
.'</td><td width=350><img width=80 height=80 src=img/loc/'.$loc_data['loc_image'].'></td></tr></table>'
.'<br><a href="?delete='.$loc_data['loc_id'].'">Supprimer</a> - '
.'<a href="?edit='.$loc_data['loc_id'].'">Modifier</a><br><hr>'
;
}
}
?>
</fieldset>
<br>
</td>
</tr>
</table>
<table class=frame cellpadding=0 cellspacing=0 width=700 height=18 border=1 align=center>
<tr>
<td align=center bgcolor=#660000>©2006</td>
</tr>
</table>
</body>
</html>
Hello et merci de ta reponse !
Je ne me suis pas découragé ^^
Du coup je suis parvenu à faire cela !
Je ne parviens ceci dit pas à faire ensorte que l'utilisateur puisse faire un upload du fichier et que celui ci soit mis dans la valeur de loc_image.
Autre chose idiote, je ne sais pas comment vérifier que les champs sont bien remplis ...
C'est pas grand chose considerant que je viens de m'y mettre seulement et que je n'y connais pas grand chose...
J'ai plus de cheveux a force de me les arracher ^^
[code]CREATE TABLE `locations` (
`loc_id` int(11) NOT NULL auto_increment,
`loc_ref` varchar(10) NOT NULL default '0',
`loc_type` varchar(50) NOT NULL default '',
`loc_surface` tinyint(4) NOT NULL default '0',
`loc_loggia` varchar(50) default NULL,
`loc_loyer` smallint(4) NOT NULL default '0',
`loc_charges` int(5) NOT NULL default '0',
`loc_frais` smallint(10) NOT NULL default '0',
`loc_lieu` varchar(128) NOT NULL default '',
`loc_dispo` date NOT NULL default '0000-00-00',
`loc_image` varchar(100) NOT NULL default '',
`loc_details` text NOT NULL,
PRIMARY KEY (`loc_id`),
KEY `loc_id` (`loc_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;[/code]
Et le code
[code]<?php
require_once 'secure/dbconnect.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
body, table {
background-color: #000000;
color: #FFFFFF;
font: normal normal 12px arial;
}
fieldset {
padding:5px;
}
.white {
font: normal bold 12px arial;
color:white;
}
.red {
font: normal bold 12px arial;
color:red;
}
INPUT.button {
cursor:hand;
font:normal bold 11px arial;
color:#FFFFFF;
border:1;
border-style:solid;
border-color:#F24343;
background-color:gray;
}
INPUT.text {
font:normal bold 12px arial;
color:#000000;
border:1;
border-style:solid;
border-color:#c0c0c0;
background-color:white;
width:200;
}
.frame {
border-collapse: collapse;
border-left: 1px solid #000000;
border-right-color: #000000;
border-right-style: solid;
border-right-width: 1px;
border-top: 1px solid #FFFFFF;
border-bottom-style: solid;
border-bottom-width: 0px;
border-bottom-color: #FFFFFF;
}
</style>
</head>
<body bgcolor=black text=white>
<table cellpadding=0 cellspacing=0 width=700 height=40 border=1 align=center class=frame>
<tr>
<td align=center bgcolor=#660000><b>Console d'administration</b></td>
</tr>
</table>
<table cellpadding=0 cellspacing=0 width=700 height=40 border=1 align=center class=frame>
<tr>
<td bgcolor=#000000>
<?
if(isset($_POST['send'])) {
if($_POST['send'] == 'new') {
$sql =
"INSERT INTO locations
(
loc_ref
,loc_type
,loc_surface
,loc_loggia
,loc_loyer
,loc_charges
,loc_frais
,loc_lieu
,loc_dispo
,loc_image
,loc_details
)
VALUES
(
'".$_POST['loc_ref']."'
,'".$_POST['loc_type']."'
,'".$_POST['loc_surface']."'
,'".$_POST['loc_loggia']."'
,'".$_POST['loc_loyer']."'
,'".$_POST['loc_charges']."'
,'".$_POST['loc_frais']."'
,'".$_POST['loc_lieu']."'
,'".$_POST['loc_dispo']."'
,'".$_POST['loc_image']."'
,'".$_POST['loc_details']."'
)";
}
elseif($_POST['send'] == 'update') {
$sql =
' UPDATE locations SET
loc_ref = "' .$_POST['loc_ref'].'"
, loc_type = "' .$_POST['loc_type'].'"
, loc_surface = "' .$_POST['loc_surface'].'"
, loc_loggia = "' .$_POST['loc_loggia'].'"
, loc_loyer = "' .$_POST['loc_loyer'].'"
, loc_charges = "' .$_POST['loc_charges'].'"
, loc_frais = "' .$_POST['loc_frais'].'"
, loc_lieu = "' .$_POST['loc_lieu'].'"
, loc_dispo = "' .$_POST['loc_dispo'].'"
, loc_image = "' .$_POST['loc_image'].'"
, loc_details = "' .$_POST['loc_details'].'"
WHERE loc_id = "' .$_POST['loc_id'].'"';
}
mysql_query($sql,$db_link) or die(mysql_error());
}
if(isset($_GET['delete']) and is_numeric($_GET['delete'])) {
mysql_query("DELETE FROM locations WHERE loc_id = \"".$_GET['delete']."\"",$db_link);
header("location: loc_admin.php");
}
if(isset($_GET['edit']) and is_numeric($_GET['edit'])) {
$Id = $_GET['edit'] ;
$sql = 'SELECT * FROM locations WHERE loc_id = "'.$Id.'" LIMIT 1' ;
$rc = mysql_query($sql,$db_link);
while($loc_data = mysql_fetch_array($rc)) {
// Modification d'une location
print '
<fieldset>
<legend>Modification d\'une location référence : '.$loc_data['loc_ref'].'</legend>
<form action="loc_admin.php" method="post" name="loc_edit">
<table>
<tr><td width=100>Référence </td><td> « <input class="text" type="text" name="loc_ref" size="10" value="'.htmlentities($loc_data['loc_ref']).'"> » Code de référence correspondant à votre logiciel de gestion</td></tr>
<tr><td>Localisation </td><td> « <input class="text" type="text" name="loc_lieu" size="10" value="'.htmlentities($loc_data['loc_lieu']).'"> » Emplacement géographique de la location</td></tr>
<tr><td>Type </td><td> « <input class="text" type="text" name="loc_type" size="10" value="'.htmlentities($loc_data['loc_type']).'"> » Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
<tr><td>Surface </td><td> « <input class="text" type="text" name="loc_surface"size="10" value="'.htmlentities($loc_data['loc_surface']).'"> » Surface habitable de la location en M²</td></tr>
<tr><td>Loggia/Terrasse </td><td> « <input class="text" type="text" name="loc_loggia" size="10" value="'.htmlentities($loc_data['loc_loggia']).'"> » Informations sur les loggias et terrasses</td></tr>
<tr><td>Loyer </td><td> « <input class="text" type="text" name="loc_loyer" size="10" value="'.htmlentities($loc_data['loc_loyer']).'"> » Loyer mensuel hors charges en euros</td></tr>
<tr><td>Charges </td><td> « <input class="text" type="text" name="loc_charges"size="10" value="'.htmlentities($loc_data['loc_charges']).'"> » Charges mensuelles en euros</td></tr>
<tr><td>Frais d\'agence </td><td> « <input class="text" type="text" name="loc_frais" size="10" value="'.htmlentities($loc_data['loc_frais']).'"> » Frais d\'agence en euros</td></tr>
<tr><td>Disponiblité </td><td> « <input class="text" type="text" name="loc_dispo" size="10" value="'.htmlentities($loc_data['loc_dispo']).'"> » Date de disposiniblité au format AAAA/MM/JJ</td></tr>
<tr><td>Details </td><td> « <input class="text" type="text" name="loc_details"size="10" value="'.htmlentities($loc_data['loc_details']).'"> » Commentaires sur l\'offre (160 caractères)</td></tr>
<tr><td>Image </td><td> « <input class="text" type="text" name="loc_image" size="10" value="'.htmlentities($loc_data['loc_image']).'"> » Photo illustrative de l\'offre</td></tr>
<tr>
<td><input class="button" type="reset" value="Annuler" onclick="javascript:history.go(-1)"></td>
<td><input class="button" type="submit" value="Valider"></td>
</tr>
<tr>
<td><input type="hidden" name="loc_id" value="'.$_GET['edit'].'"></td>
<td><input type="hidden" name="send" value="update"></td>
</tr>
</table>
</fieldset>
</form>
';
}
}
else {
//Ajout des locations
print '
<fieldset>
<legend>Ajoût d\'une location </legend>
<form action="loc_admin.php" method="post" name="loc_add">
<i>* Remplissez les champs de votre choix puis cliquer sur "Valider"</i>
<table>
<tr><td width=100>Référence </td><td> « <input class="text" type="text" name="loc_ref" size="10"> » Code de référence correspondant à votre logiciel de gestion</td></tr>
<tr><td>Localisation </td><td> « <input class="text" type="text" name="loc_lieu" size="10"> » Emplacement géographique de la location</td></tr>
<tr><td>Type </td><td> « <input class="text" type="text" name="loc_type" size="10"> » Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
<tr><td>Surface </td><td> « <input class="text" type="text" name="loc_surface" size="10"> » Surface habitable de la location en M²</td></tr>
<tr><td>Loggia </td><td> « <input class="text" type="text" name="loc_loggia" size="10"> » Informations sur les loggias et terrasses</td></tr>
<tr><td>Loyer </td><td> « <input class="text" type="text" name="loc_loyer" size="10"> » Loyer mensuel hors charges en euros</td></tr>
<tr><td>Charges </td><td> « <input class="text" type="text" name="loc_charges" size="10"> » Charges mensuelles en euros</td></tr>
<tr><td>Frais d\'agence </td><td> « <input class="text" type="text" name="loc_frais" size="10"> » Frais d\'agence en euros</td></tr>
<tr><td>Disponibilité </td><td> « <input class="text" type="text" name="loc_dispo" size="10"> » Date de disposiniblité au format AAAA/MM/JJ</td></tr>
<tr><td>Description </td><td> « <input class="text" type="text" name="loc_details" size="10"> » Commentaires sur l\'offre (160 caractères)</td></tr>
<tr><td>Image </td><td> « <input class="text" type="text" name="loc_image" size="10"> » Photo illustrative de l\'offre</td></tr>
<tr>
<td><input class="button" type="reset" value="Effacer"></td>
<td><input class="button" type="submit" value="Valider"></td>
</tr>
</table>
</fieldset>
<input type="hidden" name="send" value="new">
</form>
';
//Gestion des locations
print '<hr><fieldset><legend>Gestion des locations </legend>';
$sql = 'SELECT * FROM locations ORDER BY loc_id DESC' ;
$rc = mysql_query($sql,$db_link);
while($loc_data = mysql_fetch_array($rc)) {
print
'<table><tr><td width=350>'
.'<li>Référence : ' .$loc_data['loc_ref']
.'<li>Localisation : ' .$loc_data['loc_lieu']
.'<li>Type : ' .$loc_data['loc_type']
.'<li>Surface : ' .$loc_data['loc_surface'] . ' m²'
.'<li>Loggia / Terrasse : ' .$loc_data['loc_loggia']
.'<li>Loyer : ' .$loc_data['loc_loyer'] . ' € + '
.$loc_data['loc_charges'] .' € de charges'
.'<li>Frais d\'agence : ' .$loc_data['loc_frais'] . ' €'
.'<li>Disponibilité : ' .$loc_data['loc_dispo']
.'<li>Description : ' .$loc_data['loc_details']
.'<li>Image : ' .$loc_data['loc_image']
.'</td><td width=350><img width=80 height=80 src=img/loc/'.$loc_data['loc_image'].'></td></tr></table>'
.'<br><a href="?delete='.$loc_data['loc_id'].'">Supprimer</a> - '
.'<a href="?edit='.$loc_data['loc_id'].'">Modifier</a><br><hr>'
;
}
}
?>
</fieldset>
<br>
</td>
</tr>
</table>
<table class=frame cellpadding=0 cellspacing=0 width=700 height=18 border=1 align=center>
<tr>
<td align=center bgcolor=#660000>©2006</td>
</tr>
</table>
</body>
</html>
[/code]