html - How to return X results in PHP where variable is true -
i'm having hell of time figuring out.
i'm able pull data database no problem , show of results, however, want limit number of results returned, want show results have status of 1 , ignore 0.
here's have far...
<?php $query = "select * " . $dbtable . " order `id` desc;"; $result = mysql_query($query) or die('error: ' . mysql_error()); ?> ...other stuff... <?php while ( $row = mysql_fetch_array( $result ) ) { $username = $row["username"]; $user_photo = $row["user_photo"]; $location = $row["location"]; $status = $row["status"]; ?> <li><img src="<?= $user_photo ?>" class="collab" data-username="<?= $username ?>" data-location="<?= $location ?>" /></li> <?php } ?>
basically, i'd return first 30 results have status of 1. possible? don't have foggiest idea how approach that.
any appreciated.
use where
clause.
... status = 1 order `id` desc limit 30
for more information, visit following on mysql.com:
from manual:
select [all | distinct | distinctrow ] [high_priority] [straight_join] [sql_small_result] [sql_big_result] [sql_buffer_result] [sql_cache | sql_no_cache] [sql_calc_found_rows] select_expr [, select_expr ...] [from table_references [where where_condition] [group {col_name | expr | position} [asc | desc], ... [with rollup]] [having where_condition] [order {col_name | expr | position} [asc | desc], ...] [limit {[offset,] row_count | row_count offset offset}] [procedure procedure_name(argument_list)] [into outfile 'file_name' export_options | dumpfile 'file_name' | var_name [, var_name]] [for update | lock in share mode]]
Comments
Post a Comment