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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:36:44+00:00 2026-05-31T12:36:44+00:00

The below displays nothing. I simply want to pull the MAX number between two

  • 0

The below displays nothing. I simply want to pull the MAX number between two dates. The SQL Query actually works, and the dates are fine as they are used in other queries. It just doesn’t seem to work with the MAX selector.

$con = mysql_connect("host","user","pw");
mysql_select_db("db", $con);

//Other queries before this..
$query5="SELECT MAX(TOTALVISITS) FROM mytable WHERE DATE between '$mystartdate' and '$thedbdate'";

$result5=mysql_query($query5);
mysql_close();

$maxtotal=mysql_result($result5);

echo $MAX TOTAL: " . $maxtotal;
  • 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-31T12:36:45+00:00Added an answer on May 31, 2026 at 12:36 pm

    First, don’t call mysql_close() after mysql_query(). Your result set won’t be available for fetch.

    $result5=mysql_query($query5);
    // DON'T DO THIS!
    //mysql_close();
    

    mysql_result() takes at least two parameters – the resource and the row you want to retrieve, and optionally the column you want to retrieve. Since you have only one, the column can technically be omitted.

    // Get the first column of the first row from the result set.
    $maxvisits = mysql_result($result5, 0, 0);
    

    Note, it is good practice to assign an alias to a calculated or aggregate column:

    $query5="SELECT MAX(TOTALVISITS) AS maxvisits FROM mytable WHERE DATE between '$mystartdate' and '$thedbdate'";
    //------------------------------^^^^^^^^^^^^^^
    

    This makes it easier to use functions like mysql_fetch_assoc(), which can be a little more flexible than mysql_result():

    $row = mysql_fetch_assoc($result5);
    echo $row['maxvisits'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display data in two columns as below Entry 1 Entry 2
I am using the below HTML file. The page displays nothing and my text
The below HTML/CSS/Javascript (jQuery) code displays the #makes select box. Selecting an option displays
I have a site (link below) where the clients work displays on a long
I have a simple bit of jQuery which displays the row below the current
I have a simple requirement as mentioned below: A ListView or any control displays
In the code below, $row['site'] is an URL. In Chrome and IE8, it displays
Did you ever have a day when nothing works? Now I can't even succeed
In the below code the JProgressBar displays correctly when the doSomething() is called from
I'm using sprintf() in PHP but it displays nothing on the page. Here's what

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.