I have this query but the result just the last row in database table
(I want to show all rows in table:
$sql = mysql_query("SELECT * FROM LESSONS WHERE L_STATE='0' ORDER BY ID DESC") or die($sql_error);
if(mysql_num_rows($sql) > 0){
$resultset = array();
while($rs = mysql_fetch_assoc($sql)){
$resultset[] = $rs;
}
foreach ($resultset as $rs){
$l_id = $rs['ID'];
$l_title = $rs['L_TITLE'];
$l_comments = $rs['L_COMMENTS'];
$l_views = $rs['L_VIEWS'];
}
}else{
$l_id = $no_data;
$l_title = $no_data;
$l_comments = $no_data;
$l_views = $no_data;
}
You’re repeatedly overwriting the same variables
$l_id,$l_titleand so on with the next row until the last one… and then you’re surprised that you only get the last row?You need to have your output stuff be inside the loop for it to work.