Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-26-2009, 01:44 AM
kisazeky kisazeky is offline
Member
 
Join Date: Mar 2009
Posts: 44
Credits: 18,920
kisazeky
Default How to "buy" adoptables?

I just can't get this right: Checking if the user has enough money to adopt a certain creature.

How can I do this, if the amount of currency the user has is in the 'users' table, in the 'money' field, and the cost of the adoptable is located in the 'adoptables' table in the 'description' field?
Reply With Quote
  #2  
Old 03-26-2009, 11:02 AM
BMR777 BMR777 is offline
Member
 
Join Date: Jan 2011
Posts: 1,122
Gender: Male
Credits: 10,549
BMR777 is on a distinguished road
Default RE: How to "buy" adoptables?

You would have to get the info from both tables and store in variables. Then check if the money variable is greater than or equal to the currency in the users table. If it is, then deduct the currency and do the transaction. :)
Reply With Quote
  #3  
Old 03-26-2009, 03:13 PM
kisazeky kisazeky is offline
Member
 
Join Date: Mar 2009
Posts: 44
Credits: 18,920
kisazeky
Default RE: How to "buy" adoptables?

Quote:
Originally Posted by BMR777
You would have to get the info from both tables and store in variables. Then check if the money variable is greater than or equal to the currency in the users table. If it is, then deduct the currency and do the transaction. :)
Yeah I tried to do that, but I can't get the code to replace the "name the adoptable" article content with "you can't afford this adoptable" if they don't have enough money.

It takes me to the name the adoptable page even if I in fact have less money than the adoptable cost.

This is the code I'm using:

PHP Code:
}
else if (
$isloggedin == "yes" and $aID != ""){
//A Logged In user is adopting a new creature

//Check first that the creature does in fact exist...
//Get adoptable info
$query "SELECT * FROM adoptables WHERE uid = '$aID'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$newID=@mysql_result($result,$i,"uid");
$name=@mysql_result($result,$i,"name");
$imageurl=@mysql_result($result,$i,"imageurl");
$cost=@mysql_result($result,$i,"description");

$i++;
}
//Get how much money you have
$query "SELECT * FROM `users` WHERE `username` = '$username'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
    while (
$i 1) {
    
    
$money =@mysql_result($result,$i,"money");
    
$i++;
    }

if(
$newID != $aID){
$stop 1;
$article_title "Error";
$article_date date('Y-m-d');
$article_content "This Digimon is not available for adoption. <a href='adopt.php'>Go back</a>.";
}

//Can the user afford the adoptable?
if($money $cost){
$article_title "Oops";
$article_date date('Y-m-d');
$article_content "You can't afford this Digimon.";
}

else {
//Creature is valid, let's adopt the sucker...
//Procedure for giving the user's adoptable a name

    
if($cname == "" and $flag !=12){
    
$article_title "Adopt ".$name;
    
$article_date date('Y-m-d');
    
$article_content "<p align='left'>You are about to adopt ".$name.". </p>
<p align='left'><img src='"
.$imageurl."' border='0'></a> </p>
<p align='left'>You may give your new Digimon a nickname.  His or her name can contain letters, numbers and spaces.</p>
<form name='form1' method='get' action='adopt.php'>
  <p>
    <input name='aID' type='hidden' id='aID' value = '"
.$aID."'>
    Nickname 
    <input name='cname' type='text' id='cname' size=20 maxlength='20'>
    <input name='flag' type='hidden' id='flag' value = '12'>
  </p>
  <p>
    <input type='submit' name='Submit' value='Adopt!'>
</p>
</form>"
;
    }
    }
    }

    else{ 
Here are what the tables being referenced look like:





What is the problem?
Reply With Quote
  #4  
Old 03-26-2009, 03:23 PM
BMR777 BMR777 is offline
Member
 
Join Date: Jan 2011
Posts: 1,122
Gender: Male
Credits: 10,549
BMR777 is on a distinguished road
Default RE: How to "buy" adoptables?

I think this...

PHP Code:
if($newID != $aID){
$stop 1;
$article_title "Error";
$article_date date('Y-m-d');
$article_content "This Digimon is not available for adoption. <a href='adopt.php'>Go back</a>.";
}

//Can the user afford the adoptable?
if($money $cost){
$article_title "Oops";
$article_date date('Y-m-d');
$article_content "You can't afford this Digimon.";
}

else {
//Creature is valid, let's adopt the sucker...
//Procedure for giving the user's adoptable a name 
Needs to be:

PHP Code:
if($newID != $aID){
$stop 1;
$article_title "Error";
$article_date date('Y-m-d');
$article_content "This Digimon is not available for adoption. <a href='adopt.php'>Go back</a>.";
}
else {
//Creature is valid, let's adopt the sucker...
//Procedure for giving the user's adoptable a name

//Can the user afford the adoptable?
if($money $cost){
$article_title "Oops";
$article_date date('Y-m-d');
$article_content "You can't afford this Digimon.";
}
else{

// The code to actually adopt the pet goes here...

// End the else that processes the actual adoption 
So, first we check that the pet is valid. Then we check that the user has enough money to adopt. If both those are true then we adopt the pet. :)

Try that.
Reply With Quote
  #5  
Old 03-26-2009, 09:41 PM
kisazeky kisazeky is offline
Member
 
Join Date: Mar 2009
Posts: 44
Credits: 18,920
kisazeky
Default RE: How to "buy" adoptables?

Nope, it's still not working.

PHP Code:
//A Logged In user is adopting a new creature

//Check first that the creature does in fact exist...
$query "SELECT * FROM adoptables WHERE uid = '$aID'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$newID=@mysql_result($result,$i,"uid");
$name=@mysql_result($result,$i,"name");
$imageurl=@mysql_result($result,$i,"imageurl");
$cost=@mysql_result($result,$i,"description");

$i++;
}

$query "SELECT * FROM users WHERE uid = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$money=@mysql_result($result,$i,"money");

$i++;
}

if(
$newID != $aID){
$stop 1;
$article_title "Error";
$article_date date('Y-m-d');
$article_content "This Digimon is not available for adoption. <a href='adopt.php'>Go back</a>.";
}

else {
//Creature is valid, let's adopt the sucker...
//Procedure for giving the user's adoptable a name

//Can the user afford the adoptable?
if($money $cost){
$article_title "Oops";
$article_date date('Y-m-d');
$article_content "You can't afford this Digimon.";
}

else {
    if(
$cname == "" and $flag !=12){
    
$article_title "Adopt ".$name;
    
$article_date date('Y-m-d');
    
$article_content "<p align='left'>You are about to adopt ".$name.". </p>
<p align='left'><img src='"
.$imageurl."' border='0'></a> </p>
<p align='left'>You may give "
.$money." your new Digimon a nickname.  His or her name can contain letters, numbers and spaces.</p>
<form name='form1' method='get' action='adopt.php'>
  <p>
    <input name='aID' type='hidden' id='aID' value = '"
.$aID."'>
    Nickname 
    <input name='cname' type='text' id='cname' size=20 maxlength='20'>
    <input name='flag' type='hidden' id='flag' value = '12'>
  </p>
  <p>
    <input type='submit' name='Submit' value='Adopt!'>
</p>
</form>"
;
    }
    }
    }
    }

    else{ 
Edit: Alright, I totally ripped up your original adopt code and made it do something similar to managing your adoptables. That is, using
PHP Code:
adopt3.php?aID=aID&action=adopt 
instead of doing it all on the adopt page. Basically the adopt crap happens on adopt3.php instead of adopt.php.
Reply With Quote
  #6  
Old 03-27-2009, 06:39 PM
zhiichiro zhiichiro is offline
Member
 
Join Date: Mar 2009
Posts: 106
Credits: 11,621
zhiichiro
Default RE: How to "buy" adoptables?

WELL I HOPE WHEN IT'S DONE, I CAN MANAGE IT IN mysite.com/adm .... instead on phpmyadmin..

on the next few days my nose will bleed with those scripts.
__________________
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a "Faction" for adoptables/owned adoptables Vaporman87 Questions and Supports 1 03-04-2014 03:38 PM
Choosing Adoptables Type [EASY ADOPTABLES SCRIPT ONLY] Ashje Addons/Mods Graveyard 2 05-24-2009 03:17 AM


All times are GMT -5. The time now is 08:06 AM.

Currently Active Users: 441 (0 members and 441 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636