Forum Moderators: coopster
// sending query
$result = mysql_query("SELECT date, title FROM {$table} ORDER BY id DESC
LIMIT 5");
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
// printing table rows
while($row = mysql_fetch_row($result))
{
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "$cell<br>";
}
$query = mysql_query("SELECT * FROM {$table} ORDER BY id DESC
LIMIT 5");
$result = mysql_fetch_array($query);
then use something like this to get each seperate variable..
$title = $result[title];
$date = $result[date];
then do w/e you want with those variables...
also for your num_field just change result to query..
[edited by: GamingLoft at 2:49 am (utc) on Feb. 8, 2008]
// sending query
$result = mysql_query("SELECT date, title FROM {$table} ORDER BY id DESC
LIMIT 5");
if (!$result) {
die("Query to show fields from table failed");
}
$theresult = mysql_result($result);
// printing table rows
while($row = mysql_fetch_array($theresult))
{
$title = $row["title"];
$date = $row["date"];
echo $date . " " . $title; (Or whatever you want to do to them)
}