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

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.