Jump to content

Recommended Posts

this code works well but does not order how i want, i would like the unread to be displayed first and by date order, then the unread displayed by date order, how can i do this?

 

<?php
$query = mysql_query("SELECT * FROM mail WHERE pageid='$pageid'");
$checkbox = 1;
while ($row = mysql_fetch_assoc($query)){
$subject = $row['subject'];
$message = $row['message'];
$from = $row['from'];
$when = $row['when'];
$read = $row['read'];
$date = date("d/m/Y", strtotime(" $when +0 year ")); //this is the only way i know of changing date format

if ($read == "n")
{
$readicon = "<img src='./Images/pageimages/unread_icon.png' alt='not read'>";
$startbold = "<b>";
$endbolt = "</b>";
}
else
$readicon = "<img src='./Images/pageimages/opened_icon.png' alt='read'>";

echo "<tr><td width='40%'><hr width='100%' height='1px' color='#E6E6E6'>  <input type='checkbox' name='checkbox$checkbox'>$startbold  $readicon -  $subject $endbold </td></tr>";
$checkbox++;
}
echo "<tr><td><hr width='100%' height='1px' color='#E6E6E6'>";
?>

Link to comment
https://forums.phpfreaks.com/topic/175444-solved-ordering-results-from-db/
Share on other sites

problem is described in the code...

 

<?php
$query = mysql_query("SELECT * FROM mail WHERE pageid='$pageid' ORDER BY read, when"); //from changing this line
$checkbox = 1;
while ($row = mysql_fetch_assoc($query)){ // i get an error on this line saying "supplied argument is not a valid MySQL result"
$subject = $row['subject'];
$message = $row['message'];
$from = $row['from'];
$when = $row['when'];
$read = $row['read'];
$date = date("d/m/Y", strtotime(" $when +0 year "));
//unread = n
if ($read == "n")
{
//unread
$readicon = "<img src='./Images/pageimages/unread_icon.png' alt='not read'>";
$startbold = "<b>";
$endbolt = "</b>";
}
else
//read
$readicon = "<img src='./Images/pageimages/opened_icon.png' alt='read'>";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.