Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4551882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:41:53+00:00 2026-05-21T16:41:53+00:00

<? require(config.php); $result = mysql_query(select s_title, p_name, date from tbl_slist_info where publish=’u’ ORDER By

  • 0
<?
require("config.php");
$result = mysql_query("select s_title, p_name, date from tbl_slist_info where publish='u' ORDER By date  ") or die(mysql_error());
while($row=mysql_fetch_assoc($result))
   { ?>
  <tr>
    <td colspan="3"><?=$row['date']?></td>
  </tr>
  <tr>
   <td><a href="g.php?title=<?=$row['s_title'] ?>"><?=$row['s_title'] ?></a></td>
   <td><a href="p.php?title=<?=$row['p_name'] ?>"><?=$row['p_name'] ?></a></td>
  </tr>

I want a mysql query such that I can diplay records according to dates. Suppose at 1-Jan I have 5 requests. On 2-Jan I have 4 request. IN this way

1-Jan
_____
A   type1
B   type1
C   type2
D   type1
E   type3

2-Jan
____
W    type4
X   type1
Y   type3
Z   type5
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:41:54+00:00Added an answer on May 21, 2026 at 4:41 pm

    It is possible to do this at the database level:

    SELECT concat(date, concat('\n__________\n', 
                  group_concat(concat(concat(name, '\t'), type) SEPARATOR '\n')))
    FROM table_name
    GROUP BY date;
    

    You probably should do it at the application level: When you iterate over the result set, check if the current date is different from the date of the previous row to detect group changes.

    Edit based on the added PHP code in the question

    So something like this:

    $lastDate = null;
    while($row = mysql_fetch_assoc($result)) {
        if ($row['date'] != $lastDate) {
            echo '<tr><td colspan="2">'.htmlspecialchars($row['date']).'</td></tr>';
            $lastDate = $row['date'];
        }
        echo '<tr>';
        echo '<td><a href="g.php?title='.urlencode($row['s_title']).'">'
                  .htmlspecialchars($row['s_title']) .'</a></td>';
        echo '<td><a href="p.php?title='.urlencode($row['p_name']).'">'
                  .htmlspecialchars($row['p_name']).'</a></td>';
        echo '</tr>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use http://github.com/abraham/twitteroauth PHP library for reaching Twitter REST API: <?php session_start(); require(config.php); require(twitteroauth/twitteroauth.php);
lets say we have a directory. project/index.php in index.php <?php require 'config/config.php'; echo ROOTPATH;
I see this all the time in Ruby: require File.dirname(__FILE__) + /../../config/environment What does
I am developing a web application. contents are: root dir (/var/www/) config.php index.php details.php
Ok, So I have a external php script that get data from a DB
I have these three files to work with: document_root/include/config.php document_root/include/database.php document_root/index.php And the relevant
I require a tree / directed acyclic graph implementation something like this: public class
I require a star rating control (which allows partial rating like 4.5) for my
C# doesn't require you to specify a generic type parameter if the compiler can
Like many companies that require all access be through stored procedures, we seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.