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 04-30-2012, 05:05 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,019
SilverDragonTears is on a distinguished road
Default More fetching from tables help

This snippet of code is suppose to get the names of the parents and show them. As it is now... it shows nothing. I can get it to show the id of the parents, but I'd like it to show their names.

Code:
$result = $adopts->select("owned_adoptables", array(), "aid='{$id}'");
	while ($row = $result->fetchObject()) {
$father=$row->father;
$mother=$row->mother;

$getFather = $adopts->select("owned_adoptables", array(), "aid='{$father}'");
                         
$getMother = $adopts->select("owned_adoptables", array(), "aid='{$mother}'");
$nFather = $row->getFather;
$nFather = $nFather['name'];
$nMother = $row->getMother;
$nMother = $nMother['name'];
if(empty($row->father)) {
    $article_content .= '<b>Caught On:';
} else {
    $article_content .= '<b>Laid On:';
     
}

$article_content .= "{$row->date}<br>";



if($father == '' && $nMother == '') {
    $article_content .= '';
} else {
    $article_content .= 'Father: ' . $nFather . '<br> 
                  Mother: ' . $nMother . '<br>';
    
}

}
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 04-30-2012, 08:00 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,666
fadillzzz is an unknown quantity at this point
Default

First, grab the object instance of the result.
PHP Code:
$getFather $adopts->select("owned_adoptables", array(), "aid='{$father}'")->fetchObject(); 
Then simply fetch the property that stores the name.
PHP Code:
$getFather->name
Reply With Quote
  #3  
Old 04-30-2012, 02:12 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,019
SilverDragonTears is on a distinguished road
Default

Code:
$result = $adopts->select("owned_adoptables", array(), "aid='{$id}'");
	while ($row = $result->fetchObject()) {
$father=$row->father;
$mother=$row->mother;

$getFather = $adopts->select("owned_adoptables", array(), "aid='{$father}'")->fetchObject();
$getFather->name;    
                         
$getMother = $adopts->select("owned_adoptables", array("name"), "aid='{$mother}'");
$nFather = $nFather['name'];
$nMother = $row->getMother;
$nMother = $nMother['name'];


if($father == '' && $nMother == '') {
    $article_content .= '';
} else {
    $article_content .= 'Father: <a href="levelup.php?id='.$father.'">' . $getfather . '</a><br> 
                  Mother: ' . $nMother . '<br>';
Somehow I didn't do it right :/
__________________

Check out SilvaTales
Reply With Quote
  #4  
Old 04-30-2012, 02:45 PM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,666
fadillzzz is an unknown quantity at this point
Default

It's like this
PHP Code:
$article_content .= 'Father: <a href="levelup.php?id='.$father.'">' $getFather->name '</a><br>.....'
Reply With Quote
  #5  
Old 04-30-2012, 03:00 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,019
SilverDragonTears is on a distinguished road
Default

You the MAN!!! Thank you :D
__________________

Check out SilvaTales
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
Shop Tables SilverDragonTears Questions and Supports 1 02-02-2013 03:26 PM
Tables StarGirl Questions and Supports 3 04-26-2012 02:57 PM
Joining Tables SilverDragonTears Questions and Supports 24 04-10-2012 01:54 AM
No tables in database? Fangs Questions and Supports 1 02-28-2012 11:26 AM
Tables in myadoptables.php rosepose Questions and Supports 7 03-12-2009 06:29 PM


All times are GMT -5. The time now is 07:40 PM.

Currently Active Users: 528 (0 members and 528 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