salut j'ai un script et il me manque la structure de la table boutique ...
<?php
include('base.php');
include('tete.php');
if(!isset($_SESSION['m']['id']))
{
avert(bbCode("Il faut être connecter pour voir cette page.
"));
include('pied.php');
exit;
}
$argent = mysql_fetch_assoc(mysql_unbuffered_query('SELECT argent FROM membres WHERE id = "'.intval($_SESSION['m']['id']).'"'));
if(!isset($_SESSION['key_buy']))
{
$_SESSION['key_buy'] = md5(mt_rand('0','999999').sha1(mt_rand('0','999999
').md5(mt_rand('0','999999').time().
mt_rand('0','999999')). mt_rand('0','999999')).mt_rand('0','999999'));
}
if($_GET['key'] == $_SESSION['key_buy'])
{
if($_GET['t'] == 1)
{
if($_GET['c'] == 1)
{
$color = "green";
}
elseif($_GET['c'] == 2)
{
$color = "red";
}
elseif($_GET['c'] == 3)
{
$color = "blue";
}
elseif($_GET['c'] == 4)
{
$color = "orange";
}
elseif($_GET['c'] == 5)
{
$color = "purple";
}
$exist = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE type = "police" AND value = "'.$color.'" AND idpseudo = "'.intval($_SESSION['m']['id']).'"'));
if($exist['nb'] == 0)
{
if($argent['argent'] >= 200)
{
mysql_query('UPDATE membres SET argent=argent-200 WHERE id = "'.intval($_SESSION['m']['id']).'"');
mysql_query('INSERT INTO boutique VALUES("'.intval($_SESSION['m']['id']).'","police"
,"'.$color.'","0")');
echo '<script>window.location=\'boutique.php\';</script
';
exit;
}
else
{
avert('Vous n\'avez pas assez d\'argent.');
}
}
else
{
avert('Vous avez deja achete cet article.');
}
}
}
echo'
<style>
.bloc_article
{
border-radius:10px;
padding:10px;
opacity:0.6;
}
.bloc_article:hover
{
opacity:1;
}
</style>
<div class="logo">
<center>
<font size="12">Boutique</font>
</center>
</div>
<div id="bloc2">
<div class="texte">
<center><img src="images/boutique/argent.png" /> Vous avez <font color="green">' . htmlspecialchars($argent['argent']) . '</font></center>
</div>
</div><br />';
if(isset($_GET['t']) AND $_GET['active'] AND $_GET['key'] == $_SESSION['key_buy'])
{
mysql_query('UPDATE boutique SET active = "0" WHERE idpseudo = "'.intval($_SESSION['m']['id']).'"');
mysql_query('UPDATE boutique SET active = "1" WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND type = "'.mysql_real_escape_string($_GET['t']).'" AND value = "'.mysql_real_escape_string($_GET['active']).'"');
avert('Cette couleur a bien ete activee.');
}
?>
<h3>Couleurs de pseudo</h3>
<div class="separate"></div>
<?php
$article_buy_this = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND value = "green"'));
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<b style="color:green;">Vert</b>
<?php
if($article_buy_this['nb'] != 0)
{
?>
<span style="float:right;">Dans vos articles</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Acheter cet article ?');return(conf);" href="?t=1&c=1&key=<?php echo $_SESSION['key_buy']; ?>">Acheter</a> (Cout: 200)</span>
<?php
}
?>
</div>
</div>
<?php
$article_buy_this = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND value = "red"'));
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<b style="color:red;">Rouge</b>
<?php
if($article_buy_this['nb'] != 0)
{
?>
<span style="float:right;">Dans vos articles</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Acheter cet article ?');return(conf);" href="?t=1&c=2&key=<?php echo $_SESSION['key_buy']; ?>">Acheter</a> (Cout: 200)</span>
<?php
}
?>
</div>
</div>
<?php
$article_buy_this = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND value = "blue"'));
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<b style="color:blue;">Bleu</b>
<?php
if($article_buy_this['nb'] != 0)
{
?>
<span style="float:right;">Dans vos articles</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Acheter cet article ?');return(conf);" href="?t=1&c=3&key=<?php echo $_SESSION['key_buy']; ?>">Acheter</a> (Cout: 200)</span>
<?php
}
?>
</div>
</div>
<?php
$article_buy_this = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND value = "orange"'));
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<b style="color:orange;">Orange</b>
<?php
if($article_buy_this['nb'] != 0)
{
?>
<span style="float:right;">Dans vos articles</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Acheter cet article ?');return(conf);" href="?t=1&c=4&key=<?php echo $_SESSION['key_buy']; ?>">Acheter</a> (Cout: 200)</span>
<?php
}
?>
</div>
</div>
<?php
$article_buy_this = mysql_fetch_assoc(mysql_unbuffered_query('SELECT COUNT(*) as nb FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'" AND value = "purple"'));
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<b style="color:purple;">Violet</b>
<?php
if($article_buy_this['nb'] != 0)
{
?>
<span style="float:right;">Dans vos articles</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Acheter cet article ?');return(conf);" href="?t=1&c=5&key=<?php echo $_SESSION['key_buy']; ?>">Acheter</a> (Cout: 200)</span>
<?php
}
?>
</div>
</div>
<br />
<h3>Mes articles achetés</h3>
<div class="separate"></div>
<?php
$query = mysql_query('SELECT value,active FROM boutique WHERE idpseudo = "'.intval($_SESSION['m']['id']).'"');
$count = mysql_num_rows($query);
if($count == 0)
{
echo '<b>Vous ne possedez aucun article.</b>';
}
else
{
while($data = mysql_fetch_assoc($query))
{
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
Couleur de pseudo <b style="color:<?php echo htmlspecialchars($data['value']); ?>;"><?php echo htmlspecialchars($data['value']); ?></b>
<?php
if($data['active'] == 1)
{
?>
<span style="float:right;">Appliqué</span>
<?php
}
else
{
?>
<span style="float:right;"><a onclick="conf=confirm('Appliquer cette couleur ?');return(conf);" href="?t=police&active=<?php echo htmlspecialchars($data['value']); ?>&key=<?php echo $_SESSION['key_buy']; ?>">Appliquer</a></span>
<?php
}
?>
</div>
</div>
<?php
}
?>
<div id="bloc2" style="margin-top:2px;">
<div class="texte bloc_article">
<center>
<a onclick="conf=confirm('Appliquer la couleur par defaut ?');return(conf);" href="?t=police&active=defaut&key=<?php echo $_SESSION['key_buy']; ?>">Appliquer la couleur par defaut</a>
</center>
</div>
</div>
<?php
}
?>
<?php
include('pied.php');
?>
Donc en gros j'aurais
comme structure
idpseudo (int)
et nb (int) ?