Detox - hjælp til gammel funktion - stamtavle
Hej>>Detox du hjælp mig for et lille års tid siden med understående funktion - og den har kørt på en hjemmeside siden.
Nu skal jeg til at bruge den på min egen - men har fået et lille problem... Hanhunden skal altid sættes først - det virker på den anden side (har desværre ikke adgang mere) og jeg kan huske noget om at jeg havde givet hundhundene et 1000 og hannerne 0 til 100...
Men er der ikke en metode hvormed vi kan styre at han bliver hentet først og derefter tæven??? du får lige funktionen inkl. tabellen - og så håber jeg du har tid og lyst til at hjælpe mig
<?php
include($_SERVER["DOCUMENT_ROOT"]."/pedigree/ped_head.php");
require($_SERVER["DOCUMENT_ROOT"] . "/pedigree/funcPic.php");// Forbindelse til database
$antal = 4;// Antal generationer
$hund[0]['id'] =$_GET['id'];// valgt hunds ID
$dog = array();
$res = mysql_query("select id, name, img_path, hipp_score from pedigree where id=".$hund[0]['id']." ORDER BY id" );
$row = mysql_fetch_assoc($res);
$iddog[1]=$row['id'];
$dog[1] = $row['name'];
$img_path[1] = $row['img_path'];
$hipp_score[1] = $row['hipp_score'];
for ($i=1;$i<=$antal;$i++) {
$hund = hent($hund);// Kalder funktionen hent()
foreach ($hund as $id) {
$navne = name($id);// Kalder funktionen navn()
foreach ($navne['id'] as $item) {
$iddog[] = $item;
}
foreach ($navne['name'] as $item) {
$dog[] = $item;
}
foreach ($navne['img_path'] as $item) {
$img_path[] = $item;
}
foreach ($navne['hipp_score'] as $item) {
$hipp_score[] = $item;
}
}
}
?>
<table class="pedigree">
<tr>
<td rowspan="16" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[1]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[1]?>
<br>
<?=$hipp_score[1]?>
</a>
</td>
<td rowspan="8" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[2]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[2]?>
<br>
<?=$hipp_score[2]?>
</a>
</td>
<td rowspan="4" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[4]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[4]?>
<br>
<?=$hipp_score[4]?>
</a>
</td>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[8]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[8]?>
<br>
<?=$hipp_score[8]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[16]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[16]?>
<br>
<?=$hipp_score[16]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[17]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[17]?>
<br>
<?=$hipp_score[17]?>
</a>
</td>
</tr>
<tr>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[9]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[9]?>
<br>
<?=$hipp_score[9]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[18]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[18]?>
<br>
<?=$hipp_score[18]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[19]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[19]?>
<br>
<?=$hipp_score[19]?>
</a>
</td>
</tr>
<tr>
<td rowspan="4" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[5]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[5]?>
<br>
<?=$hipp_score[5]?>
</a>
</td>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[10]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[10]?>
<br>
<?=$hipp_score[10]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[20]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[20]?>
<br>
<?=$hipp_score[20]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[21]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[21]?>
<br>
<?=$hipp_score[21]?>
</a>
</td>
</tr>
<tr>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[11]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[11]?>
<br>
<?=$hipp_score[11]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[22]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[22]?>
<br>
<?=$hipp_score[22]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[23]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[23]?>
<br>
<?=$hipp_score[23]?>
</a>
</td>
</tr>
<tr>
<td rowspan="8" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[3]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[3]?>
<br>
<?=$hipp_score[3]?>
</a>
</td>
<td rowspan="4" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[6]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[6]?>
<br>
<?=$hipp_score[6]?>
</a>
</td>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[12]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[12]?>
<br>
<?=$hipp_score[12]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[24]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[24]?>
<br>
<?=$hipp_score[24]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[25]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[25]?>
<br>
<?=$hipp_score[25]?>
</a>
</td>
</tr>
<tr>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[13]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[13]?>
<br>
<?=$hipp_score[13]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[26]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[26]?>
<br>
<?=$hipp_score[26]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[27]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[27]?>
<br>
<?=$hipp_score[27]?>
</a>
</td>
</tr>
<tr>
<td rowspan="4" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[7]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[7]?>
<br>
<?=$hipp_score[7]?>
</a>
</td>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[14]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[14]?>
<br>
<?=$hipp_score[14]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[28]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[28]?>
<br>
<?=$hipp_score[28]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[29]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[29]?>
<br>
<?=$hipp_score[29]?>
</a>
</td>
</tr>
<tr>
<td rowspan="2" class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[15]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[15]?>
<br>
<?=$hipp_score[15]?>
</a>
</td>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[30]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[30]?>
<br>
<?=$hipp_score[30]?>
</a>
</td>
</tr>
<tr>
<td class="pedigree">
<a href='show_ped_pic.php?id=<?=$iddog[31]?>' onclick="NewWindow(this.href,'Pedigree','475','475','no','center');return false" onfocus="this.blur()">
<?=$dog[31]?>
<br>
<?=$hipp_score[31]?>
</a>
</td>
</tr>
</table>
</div>
<?
//FUNKTIONER
function hent($hund) {// Henter id's (sire & dam) på hundene i arrayet
for ($i=0;$i<count($hund);$i++) {
foreach ($hund[$i] as $id) {
$res = mysql_query("select sire, dam from pedigree where id=$id");
$row[] = mysql_fetch_assoc($res);
}
}
return $row;
}//function hent slut
function name($id) {// Henter name på sire og dam
$res = mysql_query("select id, name, img_path, hipp_score from pedigree where id=".$id['sire']." OR id=".$id['dam']);
while ($row = mysql_fetch_assoc($res)) {
$data['id'][]=$row['id'];
$data['name'][] = $row['name'];
$data['img_path'][] = $row['img_path'];
$data['hipp_score'][] = $row['hipp_score'];
}
return $data;
}//function name slut
?>
