CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

création de la table

Shaf6
Shaf6
Niveau 9
19 février 2014 à 13:09:47

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. :p)"));
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) ?

Shaf6
Shaf6
Niveau 9
19 février 2014 à 17:04:50

https://image.noelshack.com/fichiers/2014/08/1392825550-ssqss.png

les résultats

mais le problème c'est le nb il affiche 0sa vient de la variable nb

Sous forums
  • Aide à l'achat Mac
  • Création de sites web
  • Internet
  • Macintosh
  • Création de Jeux
  • Linux
  • Programmation
  • Steam Deck
  • Hardware
La vidéo du moment