Jiraiya Posted December 12, 2008 Share Posted December 12, 2008 Im trying to set up a script that changes one variable if another variable is equal to or greater then a set number. my question to you is how would i go about doing this? Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/ Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2008 Share Posted December 12, 2008 I think this is what you mean: $constant = 5; $variable = 10; if($constant >= 5) { $variable = 5; } If not please elaborate on what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714098 Share on other sites More sharing options...
Maq Posted December 12, 2008 Share Posted December 12, 2008 Why did you post this in MySQL Help? Are you extracting data from a database? Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714100 Share on other sites More sharing options...
Jiraiya Posted December 12, 2008 Author Share Posted December 12, 2008 i want to the php to check my database to verify that a variable is equal to or greater then the required number before changing the other variable Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714115 Share on other sites More sharing options...
Maq Posted December 12, 2008 Share Posted December 12, 2008 Okay, post your code a relevant code snippet, relevant table structure, and exactly what you want to do with each field. Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714123 Share on other sites More sharing options...
xtopolis Posted December 13, 2008 Share Posted December 13, 2008 Perhaps page 9 of CV's tutorial might be helpful: http://www.phpfreaks.com/tutorial/php-custom-list-order/page9 Otherwise you may need to show some code/an example so we can specifically see what needs to be changed? I'm assuming you mean changing a database variable? Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714387 Share on other sites More sharing options...
Jiraiya Posted December 13, 2008 Author Share Posted December 13, 2008 yes i do mean changing a database variable but im not sure how to write the scritp here is what i have so far $username = $_COOKIE['ID_my_site']; $sql = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); if($skill >= 5000000) { $rank = Akatsuki; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714450 Share on other sites More sharing options...
corbin Posted December 13, 2008 Share Posted December 13, 2008 Based on that script, you don't know the basic handling of MySQL stuff in PHP.... You should really look into it, but I'll just go ahead and tell you: <?php $username = $_COOKIE['ID_my_site']; //You shouldn't trust cookies! You need to atleast escape this data, and if it's used as authentication data, that's a big no-no. $sql = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); if($r = mysql_fetch_assoc($sql)) { $skill = $r['skill']; if($skill >= 5000000) { //$rank = Akatsuki; //Unless Akatsuki is a constant, it should be in quotes. $rank = 'Akatsuki'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-714588 Share on other sites More sharing options...
Jiraiya Posted December 15, 2008 Author Share Posted December 15, 2008 is this rite for updating the rank variable? $username = $_COOKIE['ID_my_site']; $sql = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); if($r = mysql_fetch_assoc($sql)) { $skill = $r['skill']; if($skill >= 5000000) { //$rank = Akatsuki; //Unless Akatsuki is a constant, it should be in quotes. $rank = 'Akatsuki'; $query = "UPDATE users rank = '$rank=Akatsuki"; Quote Link to comment https://forums.phpfreaks.com/topic/136736-solved-need-a-little-help/#findComment-715542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.