How can i let an array with 5 values....
Posted: Thu Aug 17, 2006 6:29 pm
Everah | Please use
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
How can i let an array with 5 values put de values one by one back in a print function where it will be used for a query and gives me back specific information with this print function. And it muss be done untill all te values of that array are used.Code: Select all
<?php
include('config.php');
//Thake the id from the url to work with
$Id = (isset($_GET['Id'])) ? intval($_GET['Id']) : 0 ;
$where = ($Id != 0) ? " WHERE Id=".$Id : " ";
//The function that i want to use for printing the details, and where the values have to go, one by on (6638,6642,6691,7470,7476)
function Print_distinct_mother ($mother){
$sql = "SELECT * FROM dog_table WHERE Id = $mother";
$sql_result = mysql_query($sql) or die(mysql_error());
$sql_row = mysql_fetch_assoc($sql_result);
$Id = $mother['Id'];
$DOB1 = $mother['DOB'];
$DOB = date('d M Y', strtotime($DOB1));
$Image_folder = "<img src=\"../pictures/andere/new.gif\" width=\"35\" height=\"15\" />";
$new = $Image_folder;
$bewerk_datum = $mother['DOC'];
$aantal_dagen = floor(abs((strtotime($bewerk_datum)-time())/(60*60*24)));
$Image_folder2 = "<img src=\"../pictures/andere/update.gif\" width=\"47\" height=\"10\" />";
$update = $Image_folder2;
$bewerk_datum2 = $mother['DOU'];
$aantal_dagen2 = floor(abs((strtotime($bewerk_datum2)-time())/(60*60*24)));
print "<span class=\"style2\">".$mother['Ch']."</span>\n";
print "</a> ";
print "<span class=\"style3\">".$mother['DogName']."</span>";
print "</a> ";
print "<span class=\"style4\">(".$mother['Color'].")</span>";
print "</a> ";
print "<span class=\"style4\">".$DOB."</span>";
print "</a>   ";
if($aantal_dagen <60){echo $new;}
//else{echo'';}
if($aantal_dagen2 <60){echo $update;}
//else{echo'';}
print "<br><font color='black' size='1' face='Arial'>";
print "  [<a href=\"pedigree.php?Id=$Id\">Pedigree]</a> ";
print "[<a href=\"breeding.php?Id=$Id\">Breeding]</a> ";
print "[<a href=\"sibling.php?Id=$Id\">Sibling]</a></font>";
}
//Search the number of the father and the mother
$SQL_parents = "SELECT FatherId, MotherId FROM dog_table WHERE Id = '".$Id."'" or die(mysql_error());
$SQL_parents_Result = mysql_query($SQL_parents);
if ($SQL_parents_Result) {
$parents_row = mysql_fetch_assoc($SQL_parents_Result);
$MotherId = $parents_row['MotherId']; //the number of the mother
$FatherId = $parents_row['FatherId']; //the number of the father
}
else {
echo $SQL_parents;
}
//Zoek de unieke teven die met de reu hebben gedekt
//Will give me the following numbers((6638,6642,6691,7470,7476)
$SQL_distinct_mother = "SELECT DISTINCT MotherId FROM dog_table where FatherId = $FatherId and MotherId != $MotherId and Id != $Id";
$SQL_distinct_mother_result = mysql_query($SQL_distinct_mother) or die(mysql_error());
if ($SQL_distinct_mother_result) {
$numRows = mysql_num_rows($SQL_distinct_mother_result);
for ($x=0;$x<$numRows;$x++) {
$row = mysql_fetch_array($SQL_distinct_mother_result);
$mother = $row['MotherId'];
//print $mother."<br>";
print Print_distinct_mother($mother);
}
}
?>Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]