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

  • Home
  • SEARCH
  • 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 8860313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:14:30+00:00 2026-06-14T15:14:30+00:00

I have a textbox which pulls the maximum value from DB. But it gives

  • 0

I have a textbox which pulls the maximum value from DB. But it gives wrong value.

Can you help figure out what went wrong here?

basicInformation function:

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) as max_booking_ref FROM `ballpark_details`");
    //Getting the max ref_id
    $values = mysql_fetch_assoc($query);    
    while ($query !=-1 && $row = mysql_fetch_assoc($query)) {
    $max = $row['max_booking_ref'];
    }
    echo print_r($values, true);
    $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['max_booking_ref)']), $rowClass);
    $html .= $this->wrapLabelTextbox($this->inputBookingRef($max), $rowClass);
    //$html .= $this->wrapLabelTextbox($this->inputBookingRef(), $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;
}

and my inputBookingRef function:

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

In this line:

echo print_r($values, true);

It’s displaying the last max value. But in my textbox it’s just giving value number 1. I don’t know what’s wrong with my codings. Any help is greatly appreciated so I could go on with my program. Thanks.

  • 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-14T15:14:31+00:00Added an answer on June 14, 2026 at 3:14 pm

    Each time you call

    mysql_fetch_assoc($query)
    

    it will give you the next value of the result.
    You have only 1 row from the query (if this is the real one).
    The row value is assigned to the $values
    and your WHILE loop should not be executed at all.

    Leave only one of the statements and it should be fine 😉

    EDIT after comment:
    also what is the purpose of
    $values++; in the inputBookingRef() method

    $values is probably of type string .. ++ will make it something funny.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox which can return various strings ranging from 5 characters upto
i have a textbox which is filled with date from a datepicker(calendar is accessed
I have a textbox which has the code; <input type=text maxlength=5 size=2 value=1 id=paging_textbox>
I am creating intellisense as Java's intellisense at C#.I have TextBox which user can
I have a textbox which i echo data from mysql. However if there is
I have an input textbox which is initially disabled. <input type=text name=count id=count value=0
I have a textbox which accepts Minutes. This value will be stored in a
I have a textbox which I want to set the focus on, but it
I have a textbox which has value like PN & J.I am storing it
I have TextBox which allow insert only numeric values (filtering), But when I paste

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.