Okay One more question XD

Forum
Last Post
Threads / Messages

Infernette

CODE CODE CODE CODE CODE
Member
Joined
Jan 29, 2013
Messages
164
Points
0
Location
Where I live? I live home.
Mysidian Dollar
15,625
Code:
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")."owned_adoptables WHERE owner = '{$mysidia->user->username}'")->fetchColumn();
   $rowsperpage = 10;
   $pagination = new Pagination($totaladopts, $rowsperpage, "myadopts.php");
   $pagination->setPage($mysidia->input->get("page"));
   
   $stmt = $mysidia->db->join("adoptables", "adoptables.type = owned_adoptables.type")
					   ->select("owned_adoptables", array(), constant("PREFIX")."owned_adoptables.owner = '{$mysidia->user->username}' ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}");
   $table = new Table("My Adopts", array("", "Name and Type", "Image", "Clicks", "Description"));	
   $mysidia->page->addcontent($table->getheader());
  
   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;
	  
	  $table->buildtable(array("<img src='picuploads/{$adopt->gender}.png'>", "<em>{$adopt->name}</em> the {$adopt->type}", "<a href='myadopts.php?action=manage&id={$adopt->aid}'><img src='{$image}'></a>", $adopt->totalclicks, $level->description), "center");
	  $mysidia->page->addcontent($table->showtable());	  
   }
   
   $mysidia->page->addcontent($table->endtable());
   $mysidia->page->addcontent("<br /><br />{$pagination->showPage()}</div>");   
}
For some reason it refuses to show the description I have set. Instead, it gives me a blank description column on the myadopts page.
The column is supposed to be there... The blankness, not so much XD
http://www.iaza.com/work/130213C/iaza13908934338900.png
http://www.iaza.com/work/130213C/iaza13908946877000.png
:eye:

I swear I think this hates me. XD
 
I'm not positive as I haven't done this before, but perhaps you need to add the description after $level->description. Like...
$level->description="A soft blue egg"

Or perhaps without the equals sign? I'm not sure, but I hope this helps.
 
PHP:
$table->buildtable(array("<img src='picuploads/{$adopt->gender}.png'>", "<em>{$adopt->name}</em> the {$adopt->type}", "<a href='myadopts.php?action=manage&id={$adopt->aid}'><img src='{$image}'></a>", $adopt->totalclicks, "{$level->description}"), "center");

I'm not sure, but maybe try to write "{$level->description}" instead of $level->description.This might be necessary, because your description is a text and not only a number like 'Clicks'.
 
Swan, I'm trying to get it to do it for each adoptable and not just one, so I doubt that would work well.

Isuara, tried it, to no avail :s I'm on 1.3.2 so it might be that. I dunno, I'm quite lost at this o.o
 
I tired what you supplied but it gives me the error
Parse error: syntax error, unexpected T_ELSEIF in /home/infern/public_html/myadopts.php on line 27
Do you have your entire myadopts page with that? Maybe it's something with my page down lower...
 
Parse error: syntax error, unexpected T_ELSEIF in /home/infern/public_html/myadopts.php on line 27

That might be my bad. I had edit something else in my myadopts.php. But now I used the original one and only added the description part:

PHP:
<?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")."owned_adoptables WHERE owner = '{$mysidia->user->username}'")->fetchColumn();
   $rowsperpage = 10;
   $pagination = new Pagination($totaladopts, $rowsperpage, "myadopts.php");
   $pagination->setPage($mysidia->input->get("page"));
   
   $stmt = $mysidia->db->join("adoptables", "adoptables.type = owned_adoptables.type")
					   ->select("owned_adoptables", array(), constant("PREFIX")."owned_adoptables.owner = '{$mysidia->user->username}' ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}");
   $table = new Table("My Adopts", array("", "Name and Type", "Image", "Clicks","Description"));	
   $mysidia->page->addcontent($table->getheader());
  
   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;
	  
	  $table->buildtable(array("<img src='picuploads/{$adopt->gender}.png'>", "<em>{$adopt->name}</em> the {$adopt->type}", "<a href='myadopts.php?action=manage&id={$adopt->aid}'><img src='{$image}'></a>", 
      $adopt->totalclicks,"{$level->description}"), "center");
	  $mysidia->page->addcontent($table->showtable());	  
   }
   
   $mysidia->page->addcontent($table->endtable());
   $mysidia->page->addcontent("<br /><br />{$pagination->showPage()}</div>");   
}
elseif($mysidia->input->get("id") and !is_numeric($mysidia->input->get("id"))){
   // The user has entered a non-numeric adoptable id, show error message
   $mysidia->displayerror("id");
}
else{
   // The user has entered a valid adoptable id, let's check available actions to perform
   $adopt = $mysidia->db->select("owned_adoptables", array(), "owner='{$mysidia->user->username}' and aid='{$mysidia->input->get("id")}'")->fetchObject();	  
   if(!is_object($adopt)){
      // The adoptable does not exist, show generic error message
	  $mysidia->displayerror("id");
   }
   elseif($mysidia->input->action() == "manage"){
      $image = getcurrentimage($adopt->aid);
	  $links = "<img src='{$image}'><br /><br />This page allows you to manage {$adopt->name}.  Click on an option below to change settings.<br /><br />
									<b><a href='levelup.php?id={$mysidia->input->get("id")}'><img src='templates/icons/add.gif' border=0> Level Up {$adopt->name}</a><br />
									<a href='myadopts.php?action=stats&id={$mysidia->input->get("id")}'><img src='templates/icons/stats.gif' border=0> Get Stats for {$adopt->name}</a><br />
									<a href='myadopts.php?action=bbcode&id={$mysidia->input->get("id")}'><img src='templates/icons/bbcodes.gif' border=0> Get BBCodes / HTML Codes for {$adopt->name}</a><br />
									<a href='myadopts.php?action=rename&id={$mysidia->input->get("id")}'><img src='templates/icons/title.gif' border=0> Rename {$adopt->name}</a><br />
									<a href='myadopts.php?action=trade&id={$mysidia->input->get("id")}'><img src='templates/icons/trade.gif' border=0> Change Trade Status {$adopt->name}</a><br />
									<a href='myadopts.php?action=freeze&id={$mysidia->input->get("id")}'><img src='templates/icons/freeze.gif' border=0> Freeze or Unfreeze {$adopt->name}</a><br />
									<a href='myadopts.php?action=pound&id={$mysidia->input->get("id")}'><img src='templates/icons/delete.gif' border=0> Pound {$adopt->name}</a></b>";
	  $mysidia->page->settitle("Managing {$adopt->name}");
	  $mysidia->page->addcontent($links);   
   }
   elseif($mysidia->input->action() == "stats"){ 
      $image = getcurrentimage($adopt->aid);
	  $nextlevelexists = getnextlevelexists($adopt->type, $adopt->currentlevel);
	  
	  if(!$nextlevelexists) $nloutput = $lang->maximum;
	  else{
	     $nextlevel = $adopt->currentlevel + 1;
		 $nextclicks = $mysidia->db->select("levels", array("requiredclicks"), "adoptiename='{$adopt->type}' and thisislevel='{$nextlevel}'")->fetchColumn();
 		 $ctg = $nextclicks - $adopt->totalclicks;
		 $nloutput = $nextlevel.$lang->clicks.$ctg;      		 
	  }
	  
	  $mysidia->page->settitle($adopt->name.$lang->stats);
	  $adoptstats = "<img src='{$image}'><br /><br />
				     <b>Total Clicks: {$adopt->totalclicks}<br />
				     Gender: <img src='picuploads/{$adopt->gender}.png'><br />
				     Trade Status: {$adopt->tradestatus}<br />
				     Current Level: {$adopt->currentlevel}<br />
				     Next Level: {$nloutput}<br /></b>
				     <h2>{$adopt->name}'s Voters:</h2><br />{$lang->voters}<br /><br />";
	  $mysidia->page->addcontent($adoptstats);

      $table = new Table("My Adopts", array("Username", "Date Voted", "Profile", "PM"));
	  $mysidia->page->addcontent($table->getheader());
	  
      $stmt = $mysidia->db->select("vote_voters", array(), "adoptableid='{$adopt->aid}' ORDER BY date DESC LIMIT 10");
	  while($voter = $stmt->fetchObject()) {
		 if(empty($voter->username)) $voter->username = "Guest";
		 $tablecontent = ($voter->username == "Guest")?
		                  array("Guest", $voter->date, "N/A", "N/A"):
						  array($voter->username, $voter->date, "<a href='profile.php?user={$voter->username}' target='_blank'><img src='templates/buttons/profile.gif' border=0></a>", "<a href='messages.php?action=newpm&user={$voter->username}' target='_blank'><img src='templates/buttons/pm.gif' border=0></a>");
		 $table->buildtable($tablecontent, "center");
		 $mysidia->page->addcontent($table->showtable());
      }
	  $mysidia->page->addcontent($table->endtable());
   }
   elseif($mysidia->input->action() == "bbcode"){
	  $forumcode = "{$lang->bbcode_info}<br /><p><u>Forum Codes / BBCode: </u></p><p><textarea name='textarea' cols='50' rows='4'>
	                [url=http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$adopt->aid}][img]http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$adopt->aid}[/img][/url]</textarea></p>";
	  $altcode = ($mysidia->settings->usealtbbcode == "yes")?"<p><u>Alternate BBCodes (Use if the above do not work on a forum): </u></p><p><textarea name='textarea' cols='50' rows='4'>
	             [url=http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$adopt->aid}][img]http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/get/{$adopt->aid}.gif\"[/img][/url]</textarea></p>":"";				
      $htmlcode = "<p><u>HTML Code</u>:</p><p><textarea name='textarea' cols='50' rows='4'><a href=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$adopt->aid}\" target=\"_blank\">
	              <img src=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$adopt->aid}\" border=0></a></textarea></p>";
	  $mysidia->page->settitle($lang->bbcode.$adopt->name); 
      $mysidia->page->addcontent($forumcode.$altcode.$htmlcode);	  
   }
   elseif($mysidia->input->action() == "rename"){
      $image = getcurrentimage($adopt->aid);
      if(!$mysidia->input->post("adoptname")){
	     $renameform = "<img src='{$image}'><br />{$lang->rename_default}{$adopt->name}{$lang->rename_details}<br />
						<form name='form1' method='post' action='myadopts.php?action=rename&id={$adopt->aid}'><p>Adoptable Name: 
						<input name='adoptname' type='text' id='adoptname'>
						<input name='id' type='hidden' id='id' value='{$adopt->aid}'>
						<input name='action' type='hidden' id='action' value='rename'>
						</p><p><input type='submit' name='Submit' value='Rename Adoptable'></p></form>";
	     $mysidia->page->settitle($lang->rename.$adopt->name);
		 $mysidia->page->addcontent($renameform);
	  }
	  else{
	     $poundpet = $mysidia->db->select("pounds", array(), "aid='{$mysidia->input->post("id")}'")->fetchObject();
	     if(!empty($poundpet->firstowner) and $mysidia->user->username != $poundpet->firstowner){
            $mysidia->page->settitle($lang->rename_error);
			$mysidia->page->addcontent($lang->rename_owner);               
         }
         else{						
			$mysidia->db->update("owned_adoptables", array("name" => $mysidia->input->post("adoptname")), "aid='{$mysidia->input->post("id")}' and owner='{$mysidia->user->username}'");
			$mysidia->page->settitle($lang->rename_success_title);
			$message = "<img src='{$image}'><br />{$lang->rename_success}{$mysidia->input->post("adoptname")}. 
					    You can now manage {$mysidia->input->post("adoptname")} on the <a href='myadopts.php?action=manage&id={$mysidia->input->post("id")}'>My Adopts</a> page";
            $mysidia->page->addcontent($message);
         }
	  }
	  // End of the rename feature
   }
   elseif($mysidia->input->action() == "trade"){
      $image = getcurrentimage($adopt->aid);
      $mysidia->page->settitle($lang->trade);
	  
	  if($mysidia->input->get("confirm") == "yes"){
	     switch($adopt->tradestatus){
		    case "fortrade":
			   $mysidia->db->update("owned_adoptables", array("tradestatus" => 'notfortrade'), "aid='{$adopt->aid}' and owner='{$mysidia->user->username}'");
			   $message = $lang->trade_disallow;
			   break;
			case "notfortrade":
			   $mysidia->db->update("owned_adoptables", array("tradestatus" => 'fortrade'), "aid='{$adopt->aid}' and owner='{$mysidia->user->username}'");
			   $message = $lang->trade_allow;
	           break;
			default:
			   $message = $lang->global_action;
		 }
	  }
      else{
		 $message = "Are you sure you wish to change the trade status of this adoptable?
					 <center><b><a href='myadopts.php?action=trade&id={$adopt->aid}&confirm=yes'>Yes I'd like to change its trade status</a></b><br /><br />
					 <b><a href='myadopts.php'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";		 		
	  }
	  $mysidia->page->addcontent($message);	
   }
   elseif($mysidia->input->action() == "freeze"){
      $image = getcurrentimage($adopt->aid);
      $mysidia->page->settitle($lang->freeze);
	  if(!$mysidia->input->get("freeze")){
	     $status = ($adopt->isfrozen == "yes")?"<img src='templates/icons/freeze.gif'> Frozen<br />":"<img src='templates/icons/unfreeze.gif'> Not Frozen<br />";
		 $go = ($adopt->isfrozen == "yes")?"<a href='myadopts.php?action=freeze&id={$adopt->aid}&freeze=no'><img src='templates/icons/unfreeze.gif' border=0> Unfreeze This Adoptable</a>":"<a href='myadopts.php?action=freeze&id={$adopt->aid}&freeze=yes'><img src='templates/icons/freeze.gif' border=0> Freeze This Adoptable</a>";
         $options = "<img src='{$image}'><br /><b>{$adopt->name}'s Current Status: {$status}</b><br />
					 {$lang->freeze}<br /><br /><b>{$go}</b><br /><br />{$lang->freeze_warning}";
		 $mysidia->page->addcontent($options);
	  }	 
	  else{
		 // We are actually freezing or unfreezing the adopt...
         switch($mysidia->input->get("freeze")){
		    case "yes":
			   $frz = "yes";
			   $message = $adopt->name.$lang->freeze_success;
               break;
            case "no":
               $frz = "no";
			   $message = $adopt->name.$lang->freeze_reverse;
               break;
            default:
               throw new Exception("Invalid action specified...");			
		 }
         $mysidia->db->update("owned_adoptables", array("isfrozen" => $frz), "aid='{$mysidia->input->get("id")}' and owner='{$mysidia->user->username}'");
		 $message .= "You may now manage {$adopt->name} on the <a href='myadopts.php?action=manage&id={$mysidia->input->get("id")}'>My Adopts</a> page";	     
         $mysidia->page->addcontent($message);
	  }
   }
   elseif($mysidia->input->action() == "pound"){
      $image = getcurrentimage($adopt->aid);
	  
	  if($mysidia->input->get("confirm") == "yes"){
	     $poundadopt = new Pound($adopt->aid, "pound");
         if($poundadopt->settings->system->active == "no"){
		    $mysidia->page->settitle($lang->global_action_title);
   	        $mysidia->page->addcontent($lang->pound_disabled);                 
         }
         elseif($poundadopt->validate() == TRUE){
	        $poundadopt->dopound();
	        $mysidia->page->settitle($lang->pound_complete); 
		    $mysidia->page->addcontent($poundadopt->message);
	     }
	     else{
		    $mysidia->page->settitle($lang->global_error); 
            $mysidia->page->addcontent($poundadopt->message);      
	     }
	  }
	  else{
	     $mysidia->page->settitle("Pound Adoptables");
		 $options = "<img src='{$image}'><br />{$lang->pound}<br /><br />{$lang->pound_warning}<br /><br />
										<center><b><a href='myadopts.php?action=pound&id={$mysidia->input->get("id")}&confirm=yes'>
										<img src='templates/icons/delete.gif' border=0> Pound {$adopt->name} - I dont want it anymore! 
										<img src='templates/icons/delete.gif' border=0></a></b><br /><br />
										<b><a href='myadopts.php'><img src='templates/icons/yes.gif' border=0> 
										DO NOT Pound {$adopt->name}! <img src='templates/icons/yes.gif' border=0></a></b></center><br />";
		 $mysidia->page->addcontent($options);								
	  }
   }
   else{
      // Invalid action specified, show generic error message
	  $mysidia->displayerror("action");
   }
}

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

$mysidia->output(); 

?>

Maybe it'll work for you now
 
sometimes php is a big mysterium :D

I'm glad, that it worked for you now.
 
Last edited:
Ill edit this in a second with my code and SS of my database, its not a big change to the core script at all.

Okay first in your MYSQL make sure you create a new table in your adopts_levels I called mine Descriptions: http://i46.tinypic.com/25zph1h.png

Then you will be able to add descriptions to the inside of the table like this:http://i49.tinypic.com/nvaxkp.png

After that you want to make sure your myadopts.php and levelup.php have the right fields in them so it can insert it into the table:
myadopts.php should look like this:

Code:
				// Determine what to show for next level:

				if($nextlevelexists == "true" and $nextlevel != ""){
					// See how many more clicks to go
					$ctg = $requiredclicks - $row->totalclicks;
					$nloutput = "{$nextlevel}<br /><b>Clicks Till Next Level:</b> {$ctg}";
				}
				else $nloutput = "Max Level";

				$article_title = "<center>{$row->name}</center>";
				$article_content = "<center><img src='{$image}'></center><br /><br />
									<font size='2px'><u><a href='myadopts.php?act=manage&id={$row->aid}'>Actions</a></u>                                                      <a href='myadopts.php?act=bbcode&id={$row->aid}'><u>Show HTML/BBCode Links</u></a><br />
									<b>Name:</b> {$row->name}                                                       <b>Owner:</b> {$owned_adoptables->owner}<br />
									<b>Race:</b> {$row->type}                                                      <b>Total Clicks:</b> {$row->totalclicks}<br />
									<b>Gender:</b> <img src='picuploads/{$row->gender}.png'>                                                             <b>Current Level:</b> {$row->currentlevel}<br />
									<b>Trade Status:</b> {$row->tradestatus}                                               <b>Next Level:</b> {$nloutput}<br /><br /></font>";


//Description
$article_content .= "<center><font size='2px'>{$levels->descriptions}<br /><br />Terran Dragons are much the same as the dragons of legend on Earth, except for the fact Terran Dragons did not go extinct. It is not uncommon for them to be bred for transportation and farm usage. Dragons are large serpentine or reptilian creatures. There are several types of dragons ranging from the smaller drake to the large Western Dragon. When it is time for dragons to be bred they are led by their handler to the Breeding Grounds where the eggs are left for other Terran's to raise and take care of them, these eggs range from the most common pest to the rarest ones owned by the leaders of Terra.</font></center>";
The {$levels->descriptions} is all you need for it to insert it into your page.

For yours I took a look and I think this is the problem :
Code:
 $table->buildtable(array("<img src='picuploads/{$adopt->gender}.png'>", "<em>{$adopt->name}</em> the {$adopt->type}", "<a href='myadopts.php?action=manage&id={$adopt->aid}'><img src='{$image}'></a>", $adopt->totalclicks, $level->description),
should be :
Code:
 $table->buildtable(array("<img src='picuploads/{$adopt->gender}.png'>", "<em>{$adopt->name}</em> the {$adopt->type}", "<a href='myadopts.php?action=manage&id={$adopt->aid}'><img src='{$image}'></a>", $adopt->totalclicks,"{$levels->description}"),
 
Last edited:
You need to make a filed in the adopts_adoptables table and then just call it where you want to show the description. I've done this with both my sites and it's not too hard if you know what you're doing. It looks really nice too.

I don't think attachments are working but I tried to attach one to show you an example.
 

Attachments

  • Screen Shot 2013-02-13 at 8.19.57 AM.jpg
    157 bytes · Views: 21
I forgot to tell you to add this:
So instead of this: (it occurs at least twice in the file)
Code:
$stmt = $adopts->query("SELECT * FROM {$prefix}owned_adoptables WHERE owner='{$loggedinname}' and aid='{$id}'");

you can use this:

Code:
$stmt = $adopts->query("SELECT * FROM {$prefix}owned_adoptables, {$prefix}levels WHERE owner='{$loggedinname}' and aid='{$id}' and type=adoptiename and currentlevel=thisislevel");

It makes it go with the current level, otherwise w/e your last level is will not have the description and it will be a little messed up :D
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top