PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function list_f() {
$sql = "SELECT f FROM users WHERE user='$name'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$friends = $row['f'];
$list_f = explode(',', $f);
for ($i=0; $i<7; $i++) {
$list_f[$i];
}
}
that is my function. My output is prodcuted using a function as well. I would like to somehow get it to display $list_f[$i] by callig it like this. Please help....
function list_f() {
$sql = "SELECT f FROM users WHERE user='$name'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$friends = $row['f'];
$list_f = explode(',', $f);
$string = ''; //Empty
for ($i=0; $i<7; $i++) {
$string .= $list_f[$i].'<br />'; //Add to it
}
return $string; //Make it the output of the function
}
That does help, but there is another part to the problem. I need to be able to call the fucntion by doing this $output .="".fucntion().""; will that actually work
?
pinehead18 wrote:That does help, but there is another part to the problem. I need to be able to call the fucntion by doing this $output .="".fucntion().""; will that actually work
?
Why are the "" quotes there either side? They serve no purpose
But yes - if $output is an existing string it will append to it.
am i even calling the fucntion right? becuase it will not print anything, even out of $output.. however if i take the array out of the function and echo it.. it echo's the correct info.