Jump to content

Recommended Posts

more specifically, with this code?

<?php
session_start(); // Must start session first thing
/* 
Created By Adam Khoury @ www.flashbuilding.com 
-----------------------June 20, 2008----------------------- 
*/
// Here we run a login check
if (!isset($_SESSION['id'])) { 
   echo 'Please <a href="/login.php">log in</a> to access your account';
   exit(); 
}

//Connect to the database through our include 
include_once "connect_to_mysql.php";
// Place Session variable 'id' into local variable
$userid = $_SESSION['id'];
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$name = $row["name"];
$phone = $row["phone"];
$username = $row["username"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
$cell = $row["cell"];
$email = $row["email"];
$accounttype = $row["accounttype"];
$rank = $row["rank"];
$badges = $row["badges"];
$userid = $row["userid"];

}
?>

<?php
include 'config.php';
include 'opendb.php';

// if no id is specified, list the available articles

if(!isset($_GET['id']))
{

   $query = "SELECT * FROM messages WHERE recipient ='$name' order by date desc";
   $result = mysql_query($query) or die('Error : ' . mysql_error());

   // create the article list
   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
list($from1, $recipient, $title1, $content, $id, $date, $read) = $row; 

if ($read == "1"){

$content1 .= 
"<table border='0' cellpadding='0' cellspacing='0' width='1200'> 
<tr><td valign='top' width='274'>
$from1</td> 
<td valign='top' border='1' width='1025'><a href='message.php?id=$id'>$title1</a></td></tr></table><br />
";
   }else{
$content1 .= 
"<table border='0' cellpadding='0' cellspacing='0' width='1200'> 
<tr bgcolor='#CCCC99'><td width='274'><strong>$from1</strong></td><td width='1025'>
<a href='read.php?id=$id'>$title1</a></td></tr></table><br />
";
  }}
  


   }else {
   // get the article info from database
   $query = "SELECT * FROM messages WHERE recipient='$name' ORDER by date desc";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
   $row = mysql_fetch_array($result, MYSQL_ASSOC);

   $title = $row['title'];
   $content = $row['content'];
   $to = $row['recipient'];
   $from = $row['from1'];
   $id = $row['id'];
   $read = $row['read'];

}


// if no id is specified, list the available articles
if(!isset($_GET['id']))
{
   $self = $_SERVER['PHP_SELF'];

   $query = "SELECT * FROM comments WHERE recipient='$name' order by date desc";
   $result = mysql_query($query) or die('Error : ' . mysql_error());

   // create the article list
   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      list($com_id, $userid, $id1, $id, $recipient, $comment, $sender, $title, $date, $read) = $row;
    
 if ($read == "1"){ 

$content1 .= 
"<table border='0' cellpadding='0' cellspacing='0' width='1200'> 
<tr><td valign='top' width='274'>$sender</td> <td valign='top' width='1025'>
<a href='reply.php?com_id=$com_id'>$title</a></td></tr></table><br />
";
   }else {
$content1 .= 
"<table border='0' cellpadding='0' cellspacing='0' width='1200'> 
<tr bgcolor='#CCCC99'><td valign='top' width='274'><strong>$sender</strong></td>
<td valign='top' width='1025'><a href='read1.php?com_id=$com_id'>$title</a>
</form></td></tr></table><br />
";

   }
}

} else {
   // get the article info from database
   $query = "SELECT * FROM comments WHERE recipient='$name' order by date desc";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
   $row = mysql_fetch_array($result, MYSQL_ASSOC);

   $userid = $row['userid'];
   $id1 = $row['id1'];
   $id = $row['messageid'];
   $recipient = $row['recipient'];
   $comment = $row['comment'];
   $sender = $row['sender'];
   $title = $row['title'];
   $read = $row['read'];


}
include 'closedb.php';

?>

Link to comment
https://forums.phpfreaks.com/topic/237929-order-dates/#findComment-1222634
Share on other sites

the problem is that I want display the order from both tables, so like it would be content from table1, table2, table1.

 

it displays as table1, table1, table2.  it puts them in the correct order, but not from both tables, so all table1's first in the right order, then all table2s in the right order, I want them to "intermix" so to speak.....

Link to comment
https://forums.phpfreaks.com/topic/237929-order-dates/#findComment-1222644
Share on other sites

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.