Dethman Posted January 4, 2008 Share Posted January 4, 2008 Ok I need someone to help make me a Function... Details Below... If the sql row Mothership is 0 Display button (<form name=elemental action=elemental.php method=post> <input type=submit value="Buy Elemental for 450,000,000 Naquadah & 6,000 Untrained Units"></form>)..... And then have that button change the Mothership row to 1... Then if the sql row `Mothership` is 1 Display button (Outfit Mothership goto link /mothership.php) here is the SQL code $q = @mysql_query("select Mothership from `UserDetails` where ID='$user->ID' Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/ Share on other sites More sharing options...
Dethman Posted January 4, 2008 Author Share Posted January 4, 2008 Ok im gana try to create something you guys try to Correct it... Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430394 Share on other sites More sharing options...
Daniel0 Posted January 4, 2008 Share Posted January 4, 2008 On elemental.php, run this query: UPDATE UserDetails SET Mothership = 1 WHERE ID = '{$user->ID}' For displaying the buttons: Just use a regular if statement. Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430400 Share on other sites More sharing options...
Dethman Posted January 4, 2008 Author Share Posted January 4, 2008 //-----------BuyMS Function function BuyMS($user,$wal,$type) { $noNaquadah="Not enough Naquadah!"; $nosold="Not enough untrained units!"; if($type==0){ $pris=350000000*$wal; if($pris <= ($user->gold)){ $q = @mysql_query("select Mothership from `UserDetails` where ID='$user->ID' "); $el=mysql_fetch_array($q, MYSQL_ASSOC); if($el[]>=$wal){ $q = @mysql_query("update `UserDetails` set Mothership = 1, gold=gold-'$pris' where ID='$user->ID' "); if (!$q) {print ('Query failed: '.mysql_error()); return; } }else return $nosold; } else return $noNaquadah; } if($cgi[buyMS]){ if($cgi[Mothership]){ $wal=$cgi[Mothership];$typ=0; $detail.=Mothership($user,$wal,$typ); } //-------------Button1 <form name=Mothership action=mothership.php method=post> <input type=submit value="Buy Elemental for 450,000,000 Naquadah"></form> //-------------Button2 form name= action=mothership.php method=post> <input type=submit value="Outfit Mothership"></form> I do not know how to do if else function I got this code off someone I need someone to make an if else function for me... there are the buttons and the code...Tell me if I got the BuyMS function right? Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430404 Share on other sites More sharing options...
Dethman Posted January 4, 2008 Author Share Posted January 4, 2008 You guys are gana kill me but *BUMP* Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430420 Share on other sites More sharing options...
Dethman Posted January 4, 2008 Author Share Posted January 4, 2008 Come on Guys I have a scedual to maintain I understand that you are real busy and shouldnt have to put up with ppl like me trying to get help all I need to know is if I did it right and how to do if else statements to make buttons appear Thanx -Dethman Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430430 Share on other sites More sharing options...
GingerRobot Posted January 4, 2008 Share Posted January 4, 2008 No, we're just not going to bother to help you until you bother to enclose your code inside tags so we can actually read it. p.s. Your problem is more important than other people's because? Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430435 Share on other sites More sharing options...
Dethman Posted January 4, 2008 Author Share Posted January 4, 2008 Oops Sorry ill edit them.... Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430437 Share on other sites More sharing options...
marcus Posted January 4, 2008 Share Posted January 4, 2008 <?php function BuyMS($user, $wal, $type) { $noNaquadah = "Not enough Naquadah!"; $nosold = "Not enough untrained units!"; if ($type == 0) { $pris = 350000000 * $wal; if ($pris <= ($user->gold)) { $q = @mysql_query("select Mothership from `UserDetails` where ID='$user->ID' "); $el = mysql_fetch_array($q, MYSQL_ASSOC); if ($el[] >= $wal) { // error on this line. $q = @mysql_query("update `UserDetails` set Mothership = 1, gold=gold-'$pris' where ID='$user->ID' "); if (!$q) { print ('Query failed: ' . mysql_error()); return; } } else return $nosold; } else return $noNaquadah; } if ($cgi[buyMS]) { if ($cgi[Mothership]) { $wal = $cgi[Mothership]; $typ = 0; $detail .= Mothership($user, $wal, $typ); } } } ?> since he's lazy. Quote Link to comment https://forums.phpfreaks.com/topic/84473-small-funtion/#findComment-430438 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.