thetick Posted February 17, 2010 Share Posted February 17, 2010 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 More sharing options...
sader Posted February 17, 2010 Share Posted February 17, 2010 if($row['points']< 200) Link to comment https://forums.phpfreaks.com/topic/192442-help-with-code/#findComment-1014011 Share on other sites More sharing options...
mapleleaf Posted February 17, 2010 Share Posted February 17, 2010 mysql_query("SELECT points from members where username = '$username'") or die(mysql_error()); You might be getting $username from a session or $_POST. Not clear from your post Link to comment https://forums.phpfreaks.com/topic/192442-help-with-code/#findComment-1014013 Share on other sites More sharing options...
LeadingWebDev Posted February 17, 2010 Share Posted February 17, 2010 oh... $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 More sharing options...
thetick Posted February 17, 2010 Author Share Posted February 17, 2010 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 ..... thank you all once again Link to comment https://forums.phpfreaks.com/topic/192442-help-with-code/#findComment-1014019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.