Jump to content

[SOLVED] Instant data display on same webpage


unistake

Recommended Posts

Hello all,

 

I am trying to design a php form where when the 'submit' button(to pull information from a mysql db) is pressed, the data retrieved is displayed instantly on the same webpage without the need to refresh the page. - Is this possible with php?

 

If not I would appreciate any direction as to how to make this sort of command happen, as I have not been successful googleing it!

 

Thanks

 

Tim

You are referring to Ajax

 

if you are using extjs.com

 

script.js

var jsonStore = new Ext.data.JsonStore({
    autoLoad: true,
    autoSave: false,
    url: "ajax.db-info.php"
});

// do something with jsonStore

 

ajax.db-info.php

$query = 'SELECT * FROM tabel';
$result = mysql_query($query);
$rows = array();
if (mysql_num_rows($result)) {
     while ($row = mysql_fetch_assoc($result)) {
         $rows[] = $row;
     }
}

print json_encode($rows);

im having a bit of trouble with the above code...

 

I have 3 images that I would like to activate the above code for separate query's to display the data, however i'm not sure how to link an image to this code.

 

I'm sure its very simple, but I can't see it! Can anyone help?!

 

Thanks

 

Tim

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.