Hey!
I need help with create an sql question, I think it will look like this, but not really sure:
And where do I place the code snippet?
$query="SELECT points FROM users where id='".$_SESSION["user"]["0"]."'";
mysql_query($query, $db_id);
Code where it will be placed so it can write You have '.$poang.' points.';
I need this sql question so it can get information from database, from column points.
Right now this code jumps directly too if($poang<=0) {
$skrivut .= '<b>You dont have any points left!</b>';
<?php include "antet.php"; include "func.php";
if (!isset($_SESSION["user"][1]))
{
header('Location: login.php'); die();
}
$usr=user($_SESSION["user"][0]);
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Lottery - Win points</title>
<style type="text/css">
body { background: #CCCCCC; }
p,input { font-size: 11px; font-family: "Verdana", "Helvetica", "Arial", sans-serif; color: #244189; }
label { cursor: pointer; }
</style>
</head>
<body>
<?php
global $userrow, $db_id;
$poang = $userrow["points"];
$skrivut = $gissningar = '';
if($_POST{'ok'}) {
$poang = $_POST{'poang'};
$slump = rand(1,9);
$skrivut .= 'Random number is '.$slump.'. ';
$antal = count($_POST{'siffra'});
if (isset($antal) && !empty($antal)) {
foreach($_POST{'siffra'} as $tal) {
if(is_numeric($tal)) {
$gissningar .= ' '.$tal;
if($tal==$slump) {
$poang = $userrow['points']+100;
$query = "UPDATE users SET points=points+$poang WHERE id='".$_SESSION["user"]["0"]."' LIMIT 1";
mysql_query($query, $db_id);
}
else {
$poang = $userrow['points']-10;
$query = "UPDATE users SET points=points+$poang WHERE id='".$_SESSION["user"]["0"]."' LIMIT 1";
mysql_query($query, $db_id);
}
}
}
}
if($gissningar!='') {
$skrivut .= 'You guessed '.$gissningar.'. ';
}
if($poang<=0) {
$skrivut .= '<b>You don\nt have any points left!</b>';
}
else {
$skrivut .= 'You have '.$poang.' points.';
}
}
if($usr[7]>=10){
echo '
<p>Every number you buy costs 10 points. If you win: Your betting money + 100 points.</p>
<form action="'.$_SERVER{'PHP_SELF'}.'" method="post">
<p><input type="checkbox" name="siffra[]" id="t1" value="1" /> <label for="t1">1</label>
<input type="checkbox" name="siffra[]" id="t2" value="2" /> <label for="t2">2</label>
<input type="checkbox" name="siffra[]" id="t3" value="3" /> <label for="t3">3</label>
<input type="checkbox" name="siffra[]" id="t4" value="4" /> <label for="t4">4</label>
<input type="checkbox" name="siffra[]" id="t5" value="5" /> <label for="t5">5</label>
<input type="checkbox" name="siffra[]" id="t6" value="6" /> <label for="t6">6</label>
<input type="checkbox" name="siffra[]" id="t7" value="7" /> <label for="t7">7</label>
<input type="checkbox" name="siffra[]" id="t8" value="8" /> <label for="t8">8</label>
<input type="checkbox" name="siffra[]" id="t9" value="9" /> <label for="t9">9</label>
<input type="hidden" name="poang" value="'.$poang.'" />
<input type="submit" name="ok" value="Play" /></p>
</form>
<p>'.$skrivut.'</p>';
}else{
echo '<b><div align"center">You need at least 10 points to play!</div></b>';
}
?>
</body>
</html>