Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Adopt many adoptables at once. (http://www.mysidiaadoptables.com/forum/showthread.php?t=3823)

Aasixx 09-14-2012 04:16 PM

Adopt many adoptables at once.
 
Does anyone know how to make a code where I can set a number of adoptables (making custom adoption center/place) that they can adopt all at once? Like, let's say I set it to where you can adopt 14 horses, in the dropdown box you can choose how many you'd like to adopt 1-14 and whatever number they choose, that's how many adoptables will show up in their myadopts.php

I tried making one myself but it didn't turn out too great. Any help would be awesome! Thanks.

Hall of Famer 09-15-2012 07:20 PM

Well you can just create a textfield in adopt.php in the adoption form, in which users can enter the number of adoptables they want to adopt for this particular species.

Aasixx 09-16-2012 01:58 PM

Quote:

Originally Posted by Hall of Famer (Post 24663)
Well you can just create a textfield in adopt.php in the adoption form, in which users can enter the number of adoptables they want to adopt for this particular species.

What would I need to do to make it give that user that many adoptables? So, like I said, 14 adoptables.

Hall of Famer 09-16-2012 10:45 PM

Well you can see a section of adoption form code in adopt.php like these:

PHP Code:

            $article_content $article_content."<br><img src='{$eggimage}' border='0'><br>
            <form name='form1' method='get' action='doadopt.php'>
              <p>Adoptable Name: 
                <input name='name' type='text' id='name'>
                <input name='id' type='hidden' id='id' value='
{$id}'>
                <input name='promocode' type='hidden' id='promocode' value='
{$promocode}'>
              </p>
              <p>
                <input type='submit' name='Submit' value='Adopt Me'>
            </p> 

You can add a new textfield called 'quantity' in this form section. You can place it anywhere above the submit line and below the form opening tag:

PHP Code:

<input name='number' type='text' id='number' value='1'

Now you will need to go to doadopt.php and retrieve this number from $_GET array:
PHP Code:

$id $_GET["id"];
$promocode $_GET["promocode"];
$name $_GET["name"]; 

Add below:

PHP Code:

$number $_GET['number'

The processing of multi-adopts is quite tricky, you will need a while or for loop to complete the task. Find this section of code:

PHP Code:

                // If we can adopt this creature, do the adoption
                
if($canadopt == "yes") {
                    if (
changecash(-$row->cost$GLOBALS['loggedinname'], $GLOBALS['money'])==true) {                
                        
// BEGIN the actual adoption process

                        // First we see if we have a custom name; if not, we use the default name
                        
if($name == ""$name $row->type;

                        
// Now we determine if we are using alternate images or not

                        
$alts getaltstatus($id00);

                        
// We need a unique code for the adoptable so we can show it to the user when we're done here...

                        
$code codegen(100);
                        
$genders = array('f''m');
                        
$rand rand(0,1);
  
                        
$adopts->insert("owned_adoptables", array("aid" => NULL"type" => $row->type"name" => $name"owner" => $loggedinname"currentlevel" => 0"totalclicks" => 0"code" => $code
                                        
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender" => $genders[$rand], "lastbred" => 0));
                                                                        
                        
// Adoption complete, show the user a confirmation screen...

                        
$owned_adoptable $adopts->select("owned_adoptables", array(), "code='{$code}' and owner='{$loggedinname}'")->fetchObject();    
                        
$id $owned_adoptable->aid;

                        
$article_title $name." adopted successfully";
                        
$article_content "<img src='{$row->eggimage}'><br>{$congrats1} {$name}.  You can now manage {$name} on the 
                        <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=
{$id}'>Click Here to Manage {$name}</a><br>
                        <a href='myadopts.php?act=bbcode&id=
{$id}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br>
                        Be sure and <a href='levelup.php?id=
{$id}'>feed</a> {$name} with clicks so that they grow!";
                        unset(
$_SESSION["allow"]);
                        
// END the actual adoption process
                    
}
                    else {
                        
$article_title "Not enough money.";
                        
$article_content "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable. Earn some money and then try again.";
                    }
                } 

Replace with:

PHP Code:

                // If we can adopt this creature, do the adoption
                
if($canadopt == "yes") {
                    if (
changecash(-$row->cost*$number$GLOBALS['loggedinname'], $GLOBALS['money'])==true) {                
                        
// BEGIN the actual adoption process

                      
for(0$numberi++){

                        
// First we see if we have a custom name; if not, we use the default name
                        
if($name == ""$name $row->type;

                        
// Now we determine if we are using alternate images or not

                        
$alts getaltstatus($id00);

                        
// We need a unique code for the adoptable so we can show it to the user when we're done here...

                        
$code codegen(100);
                        
$genders = array('f''m');
                        
$rand rand(0,1);
  
                        
$adopts->insert("owned_adoptables", array("aid" => NULL"type" => $row->type"name" => $name"owner" => $loggedinname"currentlevel" => 0"totalclicks" => 0"code" => $code
                                        
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender" => $genders[$rand], "lastbred" => 0));
                                                                        
                        
// Adoption complete, show the user a confirmation screen...

                        
$owned_adoptable $adopts->select("owned_adoptables", array(), "code='{$code}' and owner='{$loggedinname}'")->fetchObject();    
                        
$id $owned_adoptable->aid;

                        
$article_title $name." adopted successfully";
                        
$article_content "<img src='{$row->eggimage}'><br>{$congrats1} {$name}.  You can now manage {$name} on the 
                        <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=
{$id}'>Click Here to Manage {$name}</a><br>
                        <a href='myadopts.php?act=bbcode&id=
{$id}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br>
                        Be sure and <a href='levelup.php?id=
{$id}'>feed</a> {$name} with clicks so that they grow!";
                        unset(
$_SESSION["allow"]);
                        
// END the actual adoption process
                      
}
                    }
                    else {
                        
$article_title "Not enough money.";
                        
$article_content "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable with the entered quantity. Earn some money and then try again.";
                    }
                } 

Keep in mind that this is a drastic change of the script and I cannot promise that you won't be getting lots of unexpected errors. Lemme know if anything happens though, they should not be hard to fix.

Aasixx 09-17-2012 09:14 AM

At first I got this after pressing "Adopt Me"
Parse error: syntax error, unexpected T_IF in /home/albisian/public_html/doadopt.php on line 17

and then I added a missing ";" for this
$number = $_GET['number']

and got a new error:
Parse error: syntax error, unexpected '=', expecting ';' in /home/albisian/public_html/doadopt.php on line 47

Hall of Famer 09-17-2012 09:17 AM

Well what is line 47 for you?

Aasixx 09-17-2012 09:23 AM

Opened doadopt.php in Notepad++ and this is at line 47:
for(i = 0; i < $number; i++){

Hall of Famer 09-17-2012 09:34 AM

Oh my what was I thinking... Replace this line with the code below:

PHP Code:

for($i 0$i $number$i++){ 

Guess I was so lost in the last Java programming assignment, which does not use dollar sign as their variable name. XD

Aasixx 09-17-2012 10:14 AM

Haha, it's okay. Thank you!

Hall of Famer 09-17-2012 11:16 AM

No worries, I find it easier to use PHP's syntax though, since I am still at heart a PHP programmer. I am learning a Java course at school at this moment, hoping to strengthen my skills as an object-oriented programmer. Of course I try not to let this interfere with my php coding, since sometimes it can. XD


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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.