I want to do random adoption process so 4 random egg will appear horizontally and user can click them to adopt them and there will be no submit button or naming option and they have chances to adopt rare egg very less...
$adoptform = "<form name='form1' method='post' action='$adopt'><table id='adoptdark' name='adopt' class='adopt'>";
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$ultrarare = rand(1,200);
$legendary = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($ultrarare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($legendary==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></td>";
}
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$ultrarare = rand(1,200);
$legendary = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($ultrarare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($legendary==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform2 .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></div></td>";
}
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$ultrarare = rand(1,200);
$legendary = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($ultrarare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($legendary==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform3 .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></div></td>";
}
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}"));
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);
$adoptForm = new Form("form", "adopt", "post");
$adoptTitle = new Comment("Available Adoptables");
$adoptTitle->setHeading(3);
$adoptForm->add($adoptTitle);
$adoptTable = new Table("table", "", FALSE);
$adoptForm->add($adoptTable);
$adoptForm->add(new Button("Adopt Me", "submit", "submit"));
$document->add($adoptForm);
}
}
}
?>
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}"));
$document->add(new Comment($adoptform));
$mysidia->session->terminate("adopt");
$document->addLangvar("{$name} with clicks so that they grow!");
$mysidia->session->terminate("adopt");
return;
}
<?php
class AdoptView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("submit")){
if($mysidia->user->money < 499){
$aid = $this->getField("aid")->getValue();
$name = $this->getField("name")->getValue();
$eggImage = $this->getField("eggImage")->getValue();
$image = new Image($eggImage);
$image->setLineBreak(TRUE);
$mysidia->user->changecash(-500);
$document->setTitle("{$name} adopted successfully");
$document->add($image);
$document->addLangvar("Congratulations! You just adopted {$name}. You can now manage {$name} on the ");
$document->add(new Link("myadopts", "Myadopts Page."));
$document->add(new Comment(""));
$document->add(new Link("myadopts/manage/{$aid}", "Click Here to Manage {$name}"));
$document->add(new Comment(""));
$document->add(new Link("myadopts/bbcode/{$aid}", "Click Here to get BBCodes/HTML Codes for {$name}"));
$document->add(new Comment(""));
$document->addLangvar("Be sure and");
$document->add(new Link("levelup/{$aid}", "feed "));
$document->addLangvar("{$name} with clicks so that they grow!");
$mysidia->session->terminate("adopt");
return;
}
else{
echo "<script type='text/javascript'>alert('You do not have enough money!')</script>";
}}
$document->setTitle($mysidia->lang->title);
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);
$adoptForm = new Form("form", "adopt", "post");
$adoptTitle = new Comment("Available Species");
$adoptTitle->setHeading(3);
$adoptForm->add($adoptTitle);
$adoptTable = new Table("table", "", FALSE);
$adoptform = "<form name='form1' method='post' action='$adopt'> <table id='adoptdark' name='adopt' class='adopt'>";
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$veryrare = rand(1,200);
$endangered = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($veryrare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($endangered==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center></td>";
}
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$veryrare = rand(1,200);
$endangered = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($veryrare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($endangered==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform2 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>";
}
$common = 0;
$uncommon = rand(1,50);
$rare = rand(1,100);
$veryrare = rand(1,200);
$endangered = rand(1,300);
if ($uncommon==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($rare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($veryrare==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else if ($endangered==1 && $onlyone==0){
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";
$onlyone = 1;
}
else{
$query = "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";
}
$stmt = $mysidia->db->query($query);
while($row = $stmt->fetchObject()) {
$adoptform3 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>";
}
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}"));
$adoptForm->add($adoptTable);
$adoptSubtitle = new Comment("Adopt");
$adoptSubtitle->setHeading(3);
$adoptForm->add($adoptSubtitle);
$adoptForm->add(new Comment("Adoptable Name: ", FALSE));
$adoptForm->add(new TextField("name"));
$adoptForm->add(new Comment(""));
$adoptForm->add(new Button("Adopt Me", "submit", "submit"));
$document->add($adoptForm);
}
}
?>