Below is my code for the function I am using to retrieve multiple data from my table, but I would like to use bind_result($array[0],...,..) to be generated automatically depending on number of fields i am selecting in the query.
for example..
$query=select a,b,c,d,e from table;//selecting 5 fields
......
$stmt->execute();$stmt->bind_result($retrieve[0],$retrieve[1],$retrieve[2],$retrieve[3],$retrieve[4]);
(the bind_result for 5 values should be automatically generated)
Help will be appreciated ...Thanks
$query="SELECT comment, userid,UNIX_TIMESTAMP(dtime)
FROM comment_updates
WHERE updateid=46546
ORDER BY dtime DESC
LIMIT 10 ";
if($stmt = $this->conn->prepare($query)) {
$stmt->execute();
$stmt->bind_result($comments[0],$comments[1],$comments[2]);
$i=0;
while($stmt->fetch()){
$i++;
$name='t'.$i;
$$name = array($comments[0],$comments[1],$comments[2]);
}
return array($i,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10);
$stmt->close();
}