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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:59:39+00:00 2026-06-14T12:59:39+00:00

I have a problem with my query not fetching the max record and also

  • 0

I have a problem with my query not fetching the max record and also it’s not incrementing.
can you help me figure what is wrong with my code?

 private function basicInformation() {
    // initialize variables
    $host = "localhost";
    $db_name = "test";
    $tbl_name = "ballpark_details";
    $username = "root";
    $password = "";

    // connect to database
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB"); # ORDER BY ballpark_details_id DESC
    $query = mysql_query("SELECT MAX(ballpark_details_booking_ref) FROM `ballpark_details`");
    //Getting the max ref_id
    $values = mysql_fetch_assoc($query);    
    $html = "";
    $html .= '<fieldset id="basic-information" class="ui-widget">' . PHP_EOL;
    $html .= '<legend>Basic Ballpark Information</legend>' . PHP_EOL;
    $rowClass = "input-row";
    $html .= $this->wrapLabelTextbox($this->inputBookingRef($values['ballpark_details_booking_ref']), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputBank(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputRegion(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputDescription(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputNotes(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputStartDate(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputRequestedDeliveryDate(), $rowClass); #$this->inputEndDate()
    $html .= $this->wrapLabelTextbox($this->inputExpiryDate(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputURL(), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputCAR(), $rowClass);
    (strcmp($_GET["page"], "createballpark"))?
        $html .= $this->wrapLabelTextbox($this->inputProjectStatusEdit(), $rowClass) :
        $html .= $this->wrapLabelTextbox($this->inputProjectStatusCreate(), $rowClass);         
    $html .= '</fieldset>';
    return $html;
}


private function inputBookingRef($value){ //($value) {
    //$value = $this->bookingRef;
    $html = "";
    //$value = 10307;
    $value++;
    $html .= '<label for="ref">Booking Ref: </label>';
    $html .= HTML::inputText("ref", 20, $value) . PHP_EOL;
    return $html;
}

In here, I want to increment the value in booking ref. textbox. But when I try to run the program, it’s giving number 1 not the last max value.

  • 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-14T12:59:41+00:00Added an answer on June 14, 2026 at 12:59 pm
    $values = mysql_fetch_assoc($query); 
    

    $values does not contain the value of MAX.

    So you will have to use.

    $query = "SELECT MAX(ballpark_details_booking_ref) AS MAXValue FROM `ballpark_details`";
    
    $result = mysql_query($query, $conn) or die ("The Following query is not properly executed: ".$query."<br>");
    
    //Getting the max ref_id
    
    while ($result !=-1 && $row = mysql_fetch_assoc($result)) {
    $max = $row['MAXValue'];
    }
    

    Then

    $html .= $this->wrapLabelTextbox($this->inputBookingRef($max), $rowClass);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with SQL query. If given order contains items, witch does not
I have a problem with an sql query that will not work if I
I have a mysql problem, my query looks as follows but not complete SELECT
I have a weird problem. When I execute a query the data is not
I have the problem that the query I use for finder_sql is not parsed
I have a problem with a query that works in phpmyadmin but not with
I have problem with this query, complexity of this query is not good, i
I have problem with my query on C, I’m using the oci8 driver. This
I have a problem with a query. This query works with phpMyAdmin, but I
I have a problem with the query below in postgres SELECT u.username,l.description,l.ip,SUBSTRING(l.createdate,0,11) as createdate,l.action

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.