I am using the amCharts javascript library to show some data charts in my website. I want to read the data that will be in the charts from a database.
I'm reading the data with and after that making a call to the javascript function like this:
<?php
echo '<script language="javascript">makeGraph(' . json_encode($data) . ')</script>';
?>
I am getting the results I want this way, but if a client look in the source code of the website, he will see all the data from the database instead of $data since you are not in the server anymore.
So the question is: how can I read and use all the data without exposing it publicly? Because I can not really figure out any other way to do it now.
Thank you very much
If you don't want users to see your data, then don't use JavaScript to process it. Create the charts in php on your server and display the results only.
Related
i want to know which one is more faster/reliable or compact if we drive data from mysql and make json code of it and fetch it through ajax and print it or we directly print data in a web page.so please tell me in detail.
I want to get the content of this 1st and 2nd webpage https://www.goodreads.com/search?utf8=%E2%9C%93&q=%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9&search_type=books
and then store it in my database and then make the list is searchable.so after I googled I found that I can do it like this
$url = "https://www.goodreads.com/search?utf8=%E2%9C%93&q=%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9&search_type=books";
function get_links($url){
$input = file_get_contents($url);
echo $input;
}
get_links($url);
my problem is how can I get the 2nd page content also and how can I store these books in my database to the list searchable
The answer is not that easy...
Options
Getting the pages (Not recommended)
To get a later page you can send the "page argument" in your request:
e.g.:
https://www.goodreads.com/search?page=2&q=%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9&search_type=books&tab=books&utf8=%E2%9C%93
But to get the Elements into a nice structure you need to parse the HTML you get which is realy hard.
Use the API (recommended)
At https://www.goodreads.com/api/index you can find the documentation for goodreads API which returns example as response and is easily parseable.
Parse XML in PHP
If you use the API you can parse the XML-response with SimpleXML.
See example 1 & 2: http://php.net/manual/en/simplexml.examples-basic.php
Saving to database
If you are a beginner you might read some tutorials about how to use mysql with php and PDO. But you may also have a look at RedBeanPHP which is an really easy to use ORM for databases.
For getting 2nd page you will have to append on the url ?page=2
In case that you need to get other pages, you can use a for loop if you don't know how to use for loop, please google php for loop
For the database, google php mysql insert
I have to list the table entries from mysql in my iPhone app when a button is pressed. I am able to do it properly but it is just not the way I want it. I am using a PHP script to send Xcode what has to be printed.
First, I tried doing it using HTML table, but I didn't like the way it was printed with cells. Next I tried printing plain text by giving spaces(between columns) and \n for every new row. I used NSURL and loaded the webView to the iPhone. Looks good on browser but the same is not preserved when the iPhone tries to open it.
Is there a good way to do this? So I can just list the table entries without having to go through the traditional HTML table or any other idea is welcome.
Also, please try to be easily understood, as I am new to Obj-C, and PHP as well.
Thanks!!
Any thoughts on how I can do this in a UITableView..?? Do I have to return a string with component separation characters and fill in the tableView?
Output the results encoded in JSON. Send an a(sync) request to the server using NSURLConnection or using a third-party library such as AFNetworking. Parse the JSON using NSJSONSerialization, turning the results into an array/dictionary depending on the contents. Then parse the results into the UITableViewCell. It may be easier to subclass the cell so that you include the data that you'd like to use.
To encode the results from the database into JSON, you can use the method json_encode().
I'm trying to get data from MySql, parse it via php and echo it in json, then jquery will grab the new data and will update the table with the new data.
I have a basic table with basic data, I'm just trying to display my data dynamically for my users. When they select an option from the dropdown menu, the table will update with the new info.
I can grab the data and encode it to json. The problem I'm having is the jquery part. I don't know how to call the php json data and update the table.
I found datatables.net and their plugin is way more than what I need. I just need a simple example so I can start from there. Can someone show me a simple example of doing live queries?
Thanks!
have you tried getting a look at
http://datatables.net/release-datatables/examples/data_sources/server_side.html
update:
take a look at
http://ptheart.com/beta/testdatatables.php
and let me know if this helps.
update:
then you should try jqgrid
Hi friends i am working on JQ-GRID. I want to show Image in specific column, But i don't know how to attach image in JQ-GRID. Can anybody help me or please send me some links, thanks
jqgrid is a feature monster. I tell this everybody who asks about it.
When jqgrid loads, a function is called which actually gets the data you want to display.
This is normally an ajax call to your php. As a result set of this function, you can just use xml or json.
I prefer json, so I build my result array and do a echo json_encode($myarray)
jQuery("#your_grid_id").jqGrid({ url : '/ajax/getjqgriddata.php'})
Now displaying pictures, there are different ways you can do that. You can either generate a <img src="wherever/mypicture1.png"></img>-link and hand it over in your result, or encode your picture binary data with base64 and deliver it with your result.
A more addvanced way is to use an so called formatter and just returning a id for the image.
This depends on you, but I would suggest to get confident with jqgrid, experiment with returning -links to get a feeling how jqgrid works.
There is plenty of good documentation at:
http://trirand.com/blog/jqgrid/jqgrid.html
Just take a look at it.