I have a function in PHP that give me some values from DB
$select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
if($select){
if(mysql_fetch_row($select) != 0){
$sep = "~";
$return = "";
$i = 0;
while($row = mysql_fetch_array($select)){
if($i > 0){
$return = $return.",";
};
$return = $return.$row['id'].$sep.$row['from_'];
$i += 1;
}
return $return;
}else{
return "NO";
}
}else{
return "E, 000, SELECT, ".mysql_error();
}
The problem is that if I do like in the code above it returns me nothing, instead, if I duplicate the select variable it works:
$select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
$num_select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
if($select){
if(mysql_fetch_row($num_select) != 0){
$sep = "~";
$return = "";
$i = 0;
while($row = mysql_fetch_array($select)){
if($i > 0){
$return = $return.",";
};
$return = $return.$row['id'].$sep.$row['from_'];
$i += 1;
}
return $return;
}else{
return "NO";
}
}else{
return "E, 000, SELECT, ".mysql_error();
}
Why ?