Page 1 of 1

PHP Coding help - newbie

Posted: Sun Aug 22, 2010 2:56 pm
by mot777mot
Good day people, got this open source script for a dog pedigree database on the net. I have no programming skills at all.

Need some help with the script, i want to change the font color of the Sire's side of the pedigree that is displayed , but have no idea how to do it, any help would be appreciated.
Example of displayed pedigree - http://www.sa-apbt.co.za/details.php?id=63854
below are the code.
Thanks in advance

Code: Select all

<?php
function DbTriad($dogVO, $level, $generations, $childText) {
	global $THUMBNAIL_WIDTH;
	global $dogDAO;
	# do the individual.

	if ($level == $generations) {

		echo "<TD >"; 

	} else {

		echo "<TD ROWSPAN=" . pow(2,($generations - $level));

		echo " >"; 

	}

	if (($dogVO != -1) && (!empty($dogVO ))) {

		if (empty($dogVO)) {

			echo "Unknown Individual";

		} else {

			$name = $dogVO->name;

			$sireId = $dogVO->sire->id;

			$damId = $dogVO->dam->id;

			$landofbirth = $dogVO->landofbirth;

			$yearofbirth = $dogVO->yearofbirth;

			$color = $dogVO->color;

			$title = $dogVO->title;

			$photo = $dogVO->photo->thumb_ref;				
			if (empty($photo))
				$photo = $dogVO->photo->reference;
				}
			
			
			### Highlight title w/ Blue font

			if (!empty($title)) {
				echo "<label>";
				echo "<font color=\"blue\">$title</font><BR>";
				echo "</label>";
			}

			echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$dogVO->id.'">';					

			if (!empty($photo)) {

				echo '<p><img SRC="'.$photo.'" width="'.$THUMBNAIL_WIDTH.'"></p>';

			} 										

			echo "$name</a>";
	
				

			echo "<label>";

			//if (($level <= 3) && (!empty($color))) {

			if (!empty($color)) {

				echo "<BR>$color ";		

			}

			if (!empty($landofbirth)) {

				echo "<BR>$landofbirth";		

			}

			if (!empty($yearofbirth)) {

				echo "<BR>$yearofbirth";		

			}

			echo "</label>";
		}

	 else {

		echo "&nbsp;";

		if (!empty($childText) )		

			echo '<a href="addDog.php?child='.$childText.'">Add Dog</a>';

	}

	echo "</TD>";

# do the father.

	if ($level < $generations) {

		if (!empty($dogVO)) 

			$childText = "fatherOf_".$dogVO->id;
			
          

		else

			unset($childText);

		$dogDAO = new DogDAO();
		if (empty($sireId))
			$father = null;
		else
	    $father = $dogDAO->get($sireId);			
		DbTriad($father, $level + 1, $generations, $childText);
		
               
	}

# do the mother.
    

	if ($level < $generations) {

		if (!empty($dogVO)) 

			$childText = "motherOf_".$dogVO->id;

		else

			unset($childText);
		
		$dogDAO = new DogDAO();
		if (empty($damId))
			$mother = null;
		else 
			$mother = $dogDAO->get($damId);						
		DbTriad($mother, $level + 1, $generations, $childText);
		
	}

# finish up.

	if ($level == $generations) {

	 	echo "</TR><TR>";

	}



}





# begin table

	echo '<table id="pedigree" align="center" width="96%" border="0"><tr><th colspan='.$generations.'>Pedigree of '.$dog->name.' '.$dog->title.'</th></tr>';
	

# do tree.

	$dogDAO = new DogDAO();

	$dog = $dogDAO->get($currId);

	DbTriad ($dog, 1, $generations, null);
    

# end table

	echo "</td></tr></table>";

 ?>

Re: PHP Coding help - newbie

Posted: Sun Aug 22, 2010 5:08 pm
by somecallmejosh
There are several ways to go about this sort of thing, but font color changes are usually best handled with CSS. Are you familiar with Cascading Style Sheets?

Re: PHP Coding help - newbie

Posted: Mon Aug 23, 2010 12:20 am
by mot777mot
Thanx for the response,
Not really, only thing that i can change in the .css file is the global text color in the pedigree, and i would like to display the males in a different color than the females.
i would like to set the male and female's names in the pedigree that is generated in 2 different colors?

Re: PHP Coding help - newbie

Posted: Mon Aug 23, 2010 5:50 am
by somecallmejosh
OK. Are you unable to add information to the css file? Is there a way that you can add a class of male or female to the <td> cell that holds the dogname? I'm sure this would require a little programming (maybe someone else could help with that part?).

For instance:
<td class="male">Dogname</td>
or
<td class="female">Dogname</td>

By adding something like this to your .css file, you could control the color of the font:

.male {color:#000000;} /* Replace 000000 with the appropriate color code */
.female {color:#ff0000;} /* Replace 000000 with the appropriate color code */

Re: PHP Coding help - newbie

Posted: Mon Aug 23, 2010 10:39 am
by mot777mot
If someone can show me how or what to do i can try it!