//this is my code from class.php
class Functions
{
function getUsers($sex)
{
$stmt = $pdo->prepare('SELECT lname,fname from users WHERE gender = :gender');
$stmt->execute(array(':gender'=>$sex));
foreach($stmt as $row)
{
echo $row['lname'].'-'.$row['fname'];
//this is what i think but i don't need to echo because the echo must be in index.php.What is the right way?
}
}
$function = new Functions();
}
//this is for my index.php
include 'class.php'
$function->getUsers($gender);
//this is what i think but it is probably wrong or incomplete.
foreach(what should i put here?)
{
echo '<li>' names should be here? '</li>'
}
//the output should get all the user based on the gender :(
問題:関数の値はforeachからのものであり、値の数が固定されていないため、関数から値を取得するにはどうすればよいですか?前もって感謝します :)