crimsonduex Posted May 18, 2006 Share Posted May 18, 2006 I'm writing a script for an online breeding sim -- only I'm not sure how to make sure the numbers I'm getting are correct.<?php<br />//database queries<br />$query=mysql_query("select hid,name from horses where gender='Mare' and age > 2");<br />$num=mysql_num_rows($query);<br />if($num == "0"){<br />print "You have no mares older than two. Horses must be three or older to breed.";<br />exit;<br />}<br />else {<br />print "<form method=post action=breed.php?action=breed> Mare to cover: <select name=hid selected=selected><br />while($i<3; $i=0; $i++){<br />$row=mysql_fetch_array($query);<br />print "<option value=$row[hid]>$row[name]</option></form>";<br />}<br />//variables<br />$dadstats=array("Conformation"=>”$row[confirmation]”, "Intelligence"=>"$row[intelligence]", "Endurance"=>"$row[endurance]", "Strength"=>"$row[strength]", "Agility"=>"$row[agility]", "Speed"=>"$row[speed]");<br />$momstats= array("Conformation"=>”$row[confirmation]”, "Intelligence"=>"$row[intelligence]", "Endurance"=>"$row[endurance]", "Strength"=>"$row[strength]", "Agility"=>"$row[agility]", "Speed"=>"$row[speed]");<br />$dadcgenes=array("","");<br />$momcgenes=array("","");<br />$dadgenetics=array(“$row[bname]”,”$row[bname]”);<br />$momgenetics=array(“$row[bname]”,”$row[bname]”);<br />$foalstats=array("Conformation"=>"$v", "Intelligence"=>"$w", "Endurance"=>"$x", "Strength"=>"$y", "Agility"=>"$z", "Speed"=>"$a");<br />$foalcgenes=array("", "");<br />$foalgenetics=array(“t”,”t”);<br />//beginning computations<br />switch ($foalgenetics)<br />{<br />case Thoroughbred Quarter Horse:<br />$foalgenetics=”Appendix QH”;<br />break;<br />case Arabian Apaloosa:<br />$foalgenetics=”Ara-Apaloosa”;<br />break;<br />case Thoroughbred Arabian:<br />$foalgenetics=”Anglo-Arabian”;<br />$v=(($momstats[Conformation]+$dadstats[Conformation])*.70);<br />$w=(($momstats[Intelligence]+$dadstats[Intelligence])*.70);<br />$x=(($momstats[Endurance]+$dadstats[Endurance])*.70);<br />$y=(($momstats[Strength]+$dadstats[Strength])*.70);<br />$z=(($momstats[Agility]+$dadstats[Agility])*.70);<br />$a=(($momstats[Speed]+$dadstats[Speed])*.70);<br />array_splice($dadcgenes, 0,2,$foalcgenes);<br />array_splice($momcgenes,1,2,$foalcgenes);<br />array_splice($dadgenetics, 0,2,$foalgenetics);<br />array_splice($momgenetics,1,2,$foalgenetics);<br /><br />echo $foalstats<br />echo $foalcgenes<br />How do I make sure that I the correct numbers from the mom's db entries versus the dad's? I know I should do something with the horses' ID #, but what and how? Link to comment https://forums.phpfreaks.com/topic/9895-differentiating-between-variables/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.