Jump to content

Small Funtion


Dethman

Recommended Posts

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'

 

 

Link to comment
Share on other sites

//-----------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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.