Ankit Ankit - 27 days ago 11
MySQL Question

Use data from a database to redirect to a new page

I am using PHP, HTML and a mySQL database.

My requirements:


  1. Query for some data from the database and print it out.

  2. Compare the data with some pre-defined values.

  3. If the value is not in the range, raise a notification alert box.

  4. Once, the user clicks 'OK'--> Open up a new webpage.



For example:


  • The query result '199' is stored in
    $result
    .

  • If $result is less than 200 (true in this case) then present an
    alert
    .

  • Once the user clicks 'OK' in the
    alert
    load a new HTML page.



I am confused how to approach this.

I am able to get
$result
with a php script and display it.

Beyond that I am not able to use
$result
for comparison.

Answer
  1. You can send queries to server using ajax calls
  2. Compare the results with predefined values
  3. If a match occurs,insert the code

alert('message');
window.location = '/some/url';

Comments