Jump to content

Help with code


thetick

Recommended Posts

I am verry new to php mysql so this might be a dumb question but I just don't know.

 

I have a database something like this

table name: members

colums:

id

username

email

points

...

 

I need a mysql_query() that will sellect the points form a username and return them  as a result look below .. I need the ??????

 

  $check_if_have_points = mysql_query("?????????????????????????????") or die(mysql_error());;
  $row = mysql_fetch_array($check_if_have_points);
   echo $check_if_have_points;
if( mysql_fetch_array($row['points']) < 200){
$error_output.="You do not have enough points"; }
else {
$error_output = "Congratulations ".$username.". You now have 1 more referral. You need ".$referralsneeded." more.";
$updateuserpoints = mysql_query("UPDATE `members` SET `offer_status` = offer_status+1 WHERE `username`= '$username'") or die(mysql_error());
}

 

thank you all in advance :*

Link to comment
https://forums.phpfreaks.com/topic/192442-help-with-code/
Share on other sites

oh...  :D

$check_if_have_points = mysql_query("SELECT points FROM members WHERE username='$username'") or die(mysql_error());;
$row = mysql_fetch_array($check_if_have_points);
   echo $check_if_have_points;
if($row['points'] < 200){
$error_output.="You do not have enough points"; }
else {
$updateuserpoints = mysql_query("UPDATE `members` SET `offer_status` = offer_status+1 WHERE `username`= '$username'") or die(mysql_error());
if(!$updateuserpoints)
{
echo "error updating member";
}else{
$error_output = "Congratulations ".$username.". You now have 1 more referral. You need ".$referralsneeded." more.";
}
}

Link to comment
https://forums.phpfreaks.com/topic/192442-help-with-code/#findComment-1014015
Share on other sites

Thank you all verry much ... it works perfectly now.

   <?php
session_start();
include_once"config.php";
$username = $_SESSION['username'];
 if(isset($_POST['exchange'])){
$spoints = $_POST['spoints'];

switch ($spoints)
{
case 200:
  $check_if_have_points = mysql_query("SELECT points FROM members WHERE username = '$username'") or die(mysql_error());
  $row = mysql_fetch_array($check_if_have_points);
   echo $check_if_have_points;
if($row['points']< 200){
$error_output.="You do not have enough points"; }
else {
$error_output = "Congratulations ".$username.". You now have 1 more referral. You need ".$referralsneeded." more.";
$updateuserpoints = mysql_query("UPDATE `members` SET `offer_status` = offer_status+1 WHERE `username`= '$username'") or die(mysql_error());
}
  break;
case 400:
....................

 

Not bad after 2 days of learning php eh :P ..... thank you all once again

Link to comment
https://forums.phpfreaks.com/topic/192442-help-with-code/#findComment-1014019
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.