I have been trying to pull some information from the database and using them to generate highcharts and then show generated highcharts in certain divs on my page onchange event of the drop down. I cannot use ajax call as it doesnot support pulling highchart from another page (I already tried that). I want to do
Something like, I somehow get $_POST['dropdown'] value then use that value to get output from sql queries and then pass those values to highcharts javascripting function to generate highcharts WITHOUT PAGE LOADING.
Its very easy to do if the page gets loaded as i can generate the result in the sequence mentioned above on behalf of $_POST['dropdown'] value. Kindly Help.
Thanks,
I cannot use ajax call as it doesnot support pulling highchart from
another page (I already tried that)
Your only other option would be to load an iframe's src with JS. Why exactly can't you use Ajax?
Related
I got a page that displays a value from database that i got by fetch.
Lets say clicking a button triggers a function that changes the database value (increases it by 1).
The value is changed in the database, but the page still shows the old number.
Is there any way to update this number without refreshing the page?
Yes, there is a way of updating using JavaScript.
You can use AJAX to connect to the server without reloading the page. For an introduction in AJAX, see the MDN for the JavaScript part and the official PHP documentation for the PHP part. You can also have a look at W3Schools if you want, but don't use it as your only source of learning.
Note that you have to write JavaScript and PHP code to get it working.
I am designing a web page. I want to have the options(of another drop-down list on same page) based on the selection made by the user.
I am providing a drop-down list to the user called Application. Depending on the Application, I want to query sql and want to show only the options that are valid for selected Application in another drop-down list.
I want to get the value of Application on the same page (one that user has selected) and by getting that value will query the sql accordingly.
Once the page is loaded, the PHP cannot do anything more.
You cannot use PHP based on user interaction.
The only way to do so is through javascript.
Using ajax, you can retrieve data from a certain URL on your javascript.
A procedure would be like this:
User selects something
The javascript(ajax) loads a URL
In that URL, use your PHP to fetch a certain query
The result would be sent to javascript, so display the result.
Here's a good page explaining ajax:
http://wabism.com/ajax-tutorial-with-jquery/
you have to call an ajax function on the onchange event of dropdown that gets data from database.
ajax is your friend. Either you can use raw javascript or jquery( easier ). Your steps would be..
1. Write a php code block, most probably a function, which takes the selected application option from post, queries the database and outputs the result.
2. In your current page, write a js code that fires the ajax request each time user selects an option. This ajax will send the selected option to the php script by post method and u can grab the output upon the success of the request.
$('.selectBox').on('change', function(){
// do your ajax here.
});
something like that..
I have created a page with Mysql rows displayed as a dynamicly created image grid.
The grid display i have full control over, but i need to take the (Mysql) Row ID from each image displayed and use it in a pop up of some sort.
I don't like having a full page for each Mysql row.
It could be passing it on to a new smaller info page(dynamic) or it could be a popup with the info(dynamic).
I would prefer the popup, since i would guess this is easier on the eyes.
So what i need a suggestion on a popup function, which will load/set the row ID on click.
I have seen Jquery solutions for making popups, but i need to pass in the variables allready set by each displayed image. and this is where i fail.
Thanks in advance.
/Niels
**
This is one of the things i have tried, but i can't really figure out the way to pass it in the right way:
echo "<p>Show"
When you render the page in PHP, you could use a data attribute <div data-mydata='foo' /> to store the ID you need. Then, with jQuery, use the data() function to access the data and render whatever popup you need.
HTML 5 data attribute: http://ejohn.org/blog/html-5-data-attributes
jQuery Reference: http://api.jquery.com/data
I want to create a page where people can insert some text, hit enter, and the text be stored in a MySQL database. I can do this, but I want to be able to load a page, enter a password, and see a list of all the info in said database, then whenever something is added to the database, it's added to the list on the page, without me needing to refresh the page or setup some javascript code to refresh the page every five seconds.
I believe Satya has it correct in suggesting that you use Ajax in order to refresh the data without refreshing the page. You can have it request updated information from a php script which queries your database for the data you wish to display, and then sets the elements on your page accordingly.
this is probably the best way for you to implement ajax calls using javascript
http://api.jquery.com/jQuery.ajax/
Or you an simly do it with the help of setInterval() function. You can call an html code in a div using
$('#id').html("<htmlcode></htmlcode>");
Example : http://jsfiddle.net/ipsjolly/995PJ/6/
What I'm thinking of actually is the following: I want to have a drop-down displayed, after which I select some option, I want to run a Php that generates the options (by SQL) for a second drop-down that will appear after the first.
You could use jquery's load method which will fetch the results returned by php which in this case would be some html markup and display it in whatever div.
$('#container').load( 'phpsript.php' );
http://api.jquery.com/load/
You can use Ajax to call php script with selected option that would return a list of available options for second dropdown. You can either use JSON or XML for returning the data.
You can find an example here or here
if you want it like from the selection of first dropbox, second drop box should be dynamically generated, you should go for ajax or jquery ajax.
refer this like .. this will help you..
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_database