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)
-   -   Need a tad more help w/a page (http://www.mysidiaadoptables.com/forum/showthread.php?t=4038)

Infernette 03-09-2013 02:29 PM

Need a tad more help w/a page
 
So, I am finally setting up the adopt system that I have but the one thing I am running into is the page set up just doesn't work... Otherwise I can get it to work just fine.

I need to figure out how to get the page to show 3 random entries from the mysql database, instead of just one entry and a page that links to another. I hopefully need some help soon(trying to finish the basics so I can work on aesthetics), even if you just tell me how to make a simple page to pull 3 entries *with their same info and not just 3 random parts* and justify them (gah that would be great)...
[spoiler]
Code:

<?php

require("inc/init.php");

//***************//
//  START SCRIPT //
//***************//

if(!$mysidia->user->isloggedin){
  // The user is not logged in, show generic login error message
  $mysidia->displayerror("guest");
}
elseif(!$mysidia->input->action()){
  // No action specified yet, show the default page for myadopts.php
  $mysidia->page->settitle($lang->title);
  $totaladopts = $mysidia->db->query("SELECT count(*) FROM ".constant("PREFIX")."system_adoptables WHERE isavailable = 'yes'")->fetchColumn();
  $rowsperpage = 6;
  $editer = "Would you like to adopt a pet?";
   
  $stmt = $mysidia->db->join("adoptables", "adoptables.type = system_adoptables.type")
                      ->select("system_adoptables", array(), constant("PREFIX")."system_adoptables.isavailable = 'yes' ORDER BY RAND() LIMIT 1");
  $table = new Table("My Adopts", array(""));   
    $pagination = new Pagination($totaladopts, $rowsperpage);
  $pagination->setPage($mysidia->input->get("page"));
  while($adopt = $stmt->fetchObject()){
      $level = $mysidia->db->select("levels", array("primaryimage", "alternateimage","description"), "adoptiename='{$adopt->type}' AND thisislevel='{$adopt->currentlevel}'")->fetchObject();
      if($adopt->currentlevel == 0) $image = $adopt->eggimage; 
      elseif($adopt->usealternates == 'yes') $image = $level->alternateimage; 
      else $image = $level->primaryimage;
          if($adopt->currentlevel < '6') $gender = 'egg';
          elseif($adopt->currentlevel == '6') $gender = 'hatchling';
          else $gender = $adopt->gender;
          if($adopt->currentlevel < '8') $abandon = "<a href='myadopts.php?action=pound&id={$adopt->aid}'>Abandon</a>•";
      elseif($adopt->currentlevel == '8')$abandon = ' ';
    if($adopt->currentlevel < '6' AND $adopt->isfrozen == "no") $freeze = ' ';
                elseif($adopt->currentlevel < '8' AND $adopt->isfrozen == "no") $freeze = "<a href='myadopts.php?action=freeze&id={$adopt->aid}'>Freeze</a>•";

                elseif($adopt->currentlevel > '6' AND $adopt->isfrozen == "no") $freeze = "<a href='myadopts.php?action=freeze&id={$adopt->aid}'>Freeze</a>•";
                                        elseif($adopt->isfrozen == "yes") $freeze = " ";
                                        else $freeze = " ";
                if($adopt->isfrozen == "yes") $froze = "Frozen";
else $froze = " ";
        if($adopt->currentlevel > '5') $rename = "<a href='myadopts.php?action=rename&id={$adopt->aid}'>Rename</a>•";
                        else $rename = ' ';
          if($adopt->currentlevel > '5') $name = "{$adopt->name}";
      elseif($adopt->currentlevel < '6') $name = "{$adopt->aid}";
if($adopt->currentlevel == 0) $description = "{$adopt->description}";
else $description = "{$level->description}";
      $table->buildtable(array("<a href='adopting.php?action=adopt&id={$adopt->aid}'><img src ='{$image}></a></img>"), "center");
      $mysidia->page->addcontent($table->showtable());     
  }
   
  $mysidia->page->addcontent($table->endtable());
  $mysidia->page->addcontent("<br /><br />{$pagination->showPage()}</div>");   
}
  elseif($mysidia->input->action() == "purchase"){
  $adopt = $mysidia->db->select("system_adoptables", array(), "isavailable='yes' and aid='{$mysidia->input->get("id")}'")->fetchObject();         
$user = $mysidia->user->username;
      $image = getcurrentimage($adopt->aid);
      if(!$mysidia->input->post("adoptname")){
            $renameform = "<img src='{$image}'><br>{$adopt->gender}<br><i>{$adopt->type}</i><br><br>{$adopt->speciesd}<br />Would you like to purchase {$adopt->name}, {$user}?<br /> <br><br>This pet costs {$adopt->price} blue stones.<br> </br>
                                                <form name='form1' method='post' action='buying.php?action=purchase&id={$adopt->aid}'><p>Confirm:
                                                <input name='adoptname' type='int' id='adoptname'>
                                                <input name='id' type='hidden' id='id' value='{$adopt->aid}'>
                                                <input type='submit' name='Submit' value='Buy Adoptable'></p><br><i>You must enter a word or letter into the  box above to confirm your purchase.</form>";
            $mysidia->page->settitle('Purchasing a pet');
                $mysidia->page->addcontent($renameform);
          }

        else{
        $adopt = $mysidia->db->select("system_adoptables", array(), "isavailable='yes' and aid='{$mysidia->input->get("id")}'")->fetchObject();         
$mysidia->db->insert("messages", array("id" => NULL, "fromuser" => $user, "touser" => $adopt->owner, "status" => unread, "messagetitle" => 'Pet sold!', "messagetext" => 'Your pet has sold to this user. You have been given your asking price for the pet and it has been instantly rewarded to you.'));
            $cost = $adopt->price;
                $moneyleft = $mysidia->user->money - $adopt->price;
                $owner = $mysidia->db->select("users", array(), "username='$adopt->owner'")->fetchObject();         
                $moneyearned = $owner->money + $adopt->price;
                if($moneyleft >= 0){
            $mysidia->db->update("users", array("money" => $moneyearned), "username = '$adopt->owner'");
                        $mysidia->db->update("system_adoptables", array("owner" => $user,"isavailable" => 'no'), "aid ='$adopt->aid'");
            $mysidia->db->update("users", array("money" => $moneyleft), "username = '$user'");
                        $message = "<img src='{$image}'><br />You have purchased {$adopt->name}.<small><a href = 'buying.php'>Go back to the sales area.</a></small>";
            $mysidia->page->addcontent($message);
}
else {
$message = "You do not have enough money to purchase this pet.";
        }
          }
}

//***************//
//  OUTPUT PAGE  //
//***************//

$mysidia->output();

?>

[/spoiler]

sorry I'm so confuzzled with this @.@


All times are GMT -5. The time now is 02:57 PM.

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