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 8889495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:16:36+00:00 2026-06-14T22:16:36+00:00

I am new to php and I just developed a code looking at some

  • 0

I am new to php and I just developed a code looking at some tutorials.

<?php
ini_set('display_errors',1); 
 error_reporting(E_ALL);
include 'db_connect.php';

$query  = "SELECT id, date, ip, website FROM response";
$result = mysql_query($query);
$dateArray=array();


while($row = mysql_fetch_array($result)  or die (mysql_error()))
{
echo "Date :{$row['date']} <br>" .
     "IP : {$row['ip']} <br>" .
     "Url : {$row['website']} <br><br>";
}

?>

This displays record in this format

Date :2012-11-23 17:07:57
IP : 198.169.127.145
Url : 2webdesign.com

Date :2012-11-25 21:45:11
IP : 198.169.127.145
Url : 2webdesign.com

Date :2012-11-25 21:45:51
IP : 198.169.127.145
Url : www.sarcan.ca

I want to display records where date is on top and data is displayed under date

For instance

Date: 25 November 2012
Url 
IP

URl
IP

Date 26 Nov 2012
URL
IP

URL
IP

Secondly I also want to have an option to export this to Excelsheet.

Can anybody have a look at the code and help me out.

I know this is very basic code as I just have a basic idea oh php

  • 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-06-14T22:16:37+00:00Added an answer on June 14, 2026 at 10:16 pm

    Please keep in mind all the comments to your original post, because they are all valid. Here is a possible solution (untested, so may need light modification) to the first part of your question:

    <?php
    $query  = "SELECT DATE(date) as date, id, date as fulldate, ip, website FROM response ORDER BY date";
    
    // do query...
    
    $previousDate = "";
    while($row = mysql_fetch_assoc($result)) {
        // check to see if the previous date is different to this date
        if($previousDate != $row['date']) { // date is different; start a new heading
        ?>
    <div>Date :<?php echo $row['date']; ?></div>
        <?php } ?>
    <ul>
       <li>IP :<?php echo $row['ip']; ?></li>
       <li>Url :<?php echo $row['website']; ?></li>
    </ul>
    <?php 
        // assign current date to the $previousDate variable.
        $previousDate = $row['date'];
    } ?>    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to PHP, I practised PHP setcookie() just now and failed. http://localhost/test/
I'm new to PHP development and I just used Zend yesterday. One problem I'm
I am pretty new to PHP and MySQL and I just can't figure this
I've just started messing around with php recently and I was testing my new
I am really new to php, I have recently developed a reliability simple web
I am working through some code done by a previous developer. I'm pretty new
I'm fairly new to PHP, and I just started using NetBeans to develop my
I've inherited some PHP code that I need to make significant changes on. I
I am trying to use a PHP form (new.php) to update 2 MySQL tables
To put it simply i am a fairly new PHP coder and i was

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.