The second question of mine you replied with
$result = mysql_query("select * from table order by section asc, insertdate desc");
while($row = mysql_fetch_array($result))
{
if($thissection == $row['section'])
{
if($displayed <= 1)
{
// show record
$displayed++;
}
}
else
{
$thissection = $row['section']);
$displayed = 1;
// show record
}
}
Edited for my use would be this?
$result = mysql_query("select * from table order by group_ID DESC LIMIT 2");
while($row = mysql_fetch_array($result))
{
if($thissection == $row['group_ID'])
{
if($displayed <= 1)
{
// show record
$displayed++;
}
}
else
{
$thissection = $row['group_ID']);
$displayed = 1;
// show record
}
}
As far as I can understand it it will ask if displayed is less then or equal to 1 it will show it and if not it will show 1? How would I show 2's or 3's?? Just change the numbers?
//edit After looking it over more and trying to understand it...I have no clue what that does or where it would goto. I need a little more thorough explanation of it if that is possible. I have tried reading it and placing it but I can't figure it out. 🙁
Maybe I explained it wrong. There are 5 types of news. 5 different tables I want to display each type in. I am currently displaying the last 2 entries in the database in one table. I want each table to have one type of news and to only grab the last 2 entries for that type from the database. I am using dreamweaver cause my knowledge of php is very nil but the basics. Dreamweaver is what created that very complex php earlier that was simplied. If possible cause I want to learn this and not just get code would like it explained to me in the simplest of forms so I can build off what you guys show me. I understand the code I got earlier but the latest code for sorting is a loss to me as I have no clue what it does. Any help in the code and learning it would be greatly appreciated.
Code so far:
<?php require_once('folder/file.php'); ?>
<?php
mysql_select_db($database_insidexsi, $insidexsi);
$query_stories = "SELECT * FROM feature";
$stories = mysql_query($query_stories, $insidexsi) or die(mysql_error());
$row_stories = mysql_fetch_assoc($stories);
$totalRows_stories = mysql_num_rows($stories);
$query_stories = mysql_query("SELECT * FROM feature ORDER BY story_ID DESC LIMIT 2");
?>
Displaying results PHP:
<?php
echo "<table id=\"featable\"><tr>";
while($row_stories = mysql_fetch_array($query_stories)){
echo "<td>";
echo "<img src=\"". $row_stories['story_ImgURL'] ."\" /><br />";
echo $row_stories['story_teaser'] ."<br />";
echo "<a href=\"story_detail.php?story_ID=". $row_stories['story_ID'] ."\">Read More</a>";
echo "</td>";
}
echo "</tr></table>";
?>
I understand the first one a little bit and the second one I understand now after reading it over.