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]
Hope some one can help me with my problem:
With an url I get a number:Code: Select all
<?
$Id = (isset($_GET['Id'])) ? intval($_GET['Id']) : 0 ;
$where = ($Id != 0) ? " WHERE Id=".$Id : " ";
?>Code: Select all
<?
$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']; //De nummer van de Moeder
$FatherId = $parents_row['FatherId']; //De nummer van de Vader
?>The numbers I get from that distinct query are (6638,6642,6691,7470,7476)
Code: Select all
<?
$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);
//print $row['MotherId'];
//print $row."<br>";
foreach ($row as $sValue) {
$sql = "SELECT * FROM dog_table WHERE Id = '". $sValue ."'";
$sql_result = mysql_query($sql) or die(mysql_error());
$sql_row = mysql_fetch_assoc($sql_result);
print $sql_row['Id']."<br>";
}
}
}
?>6638
6642
6691
7470
7476
I am getting this
6638
6638
6642
6642
6691
6691
7470
7470
7476
7476
What do I wrong?
feyd | 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]