format HTML server-side or client-side? [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a PHP page that retrieves a list from the DB, and I want to display it on a loaded page using Ajax.
Should I format it on the PHP side (HTML formatting), and just retrieve the data, or pass it to JS like dataA:dataB:dataC and format it client-side?
there won't be a lot of people using it, but I would like to know which is better (if there is a better method without taking the amount of users into account)

Both will work fine. However in my opinion if you're gonna use ajax - and transfer information - a better practice will be to wrap the data in JSON format and parse it on the client's machine.
Example of the php output:
{
"row1":{"field1":"value11", "field2":"value12"}
"row2":{"field2":"value21", "field2":"value22"}
...
}
Exmaple of parsing:
$.ajax(...).done(function(result){
$.each(result, function(index,value){
$('#conatiner').append('<div>'+index+': field1='+value.field1+', field2='+value.field2+'</div>')
})
});

Related

How to give client an option to print a receipt directly from the CodeIgniter website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to give client to a print a receipt through my website directly. I know we can not do it via php because it is a serverside language. I have tried do it by using WebClientPrint.php. But I was unable to implement it. I need to know is it possible to implement such option in CodeIgniter
You need to use js for printing:
var w = window.open('files/invoices/invoice.html','name','width=800,height=500');
w.onload = w.print;
w.focus();
If you need to generate the file then use ajax to do that & then use the file path to print using above js functions.

Extracting data from a website after a delayed time with PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to extract prices from Klipsch.com but the prices don't immediately load upon loading the site, they load after the website is fully loaded using JavaScript or some other script. For example, I'm trying to extract the price from the inside of this page from the inside of this element:
<span class="product-display-price ecommerce-element">$3,284.00</span>
I've tried using Simple HTML DOM Parser but there is no delay function. I would like to achieve this in PHP but languages like Ajax would work fine too.
The site loads item details from an external javascript file. Why don't you call that file instead?
http://product.shopatron.com/product/{product_id}.jsonp?apikey={your_api_key}&...
For example, http://www.klipsch.com/products/la-scala-ii-floorstanding-speaker calls:
http://product.shopatron.com/product/1000996.jsonp?api_key=5gsk5uyr&apiVer=2.4.4&jstVer=2.4.4&method=get&headers%5BAccept%5D=*%2F*&callback=jQuery17202970524297561483_1481065390010&_=1481065390234

How to use Plesk api with php? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to use the plesk api in order to use some of its data to a web application and more specifically the data usage and the permitted storage.
I found this article but I wasn't able to find some php code on how I ll retrieve and display the data. Any guidance would be highly appreciated.
Have you checked https://docs.plesk.com/en-US/17.0/api-rpc/creating-client-software/sending-request-packets.28727/?
It shows how to create requests and next page shows response structure.
PHP examples are at https://github.com/plesk/api-examples/tree/master/php.
To display data you will have to parse the xml result first. You can use SimpleXML to do this.

How can I Print a result on webpage using php getting from MySql database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a school website, I have uploaded the students examination result to the database but now I want to make a search bar by which can the student search their result by typing their roll number.
please someone give me the code. please
#wajahat-aftab - you can always find a great tutorial to do this. Here are few of the links
https://www.youtube.com/watch?v=N_S7_wg87GU
http://html.net/tutorials/php/
http://www.htmlgoodies.com/beyond/php/article.php/3472391
Basically you need to get the data, manipulate it and send it to the HTML page. Once you get the data in HTML you can present it any kind of look-n-feel as per your needs.
You can not expect exact answers for such questions - so I suggest you to be more specific with QUESTION and make sure that you also share the source code that you tried so far.

QUERY versus PHP [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am trying to understand what medium to use to fetch data from a MySQL database using PHP.
What is better "speed" wise, jQUERY or PHP to fetch data form MySQL on page load?
With jQuery alone you can't fetch data from mysql.
If your question is to load with the page or get the data from php after loading, I can say, that loading with page is better, because the text is standing on the page when you load it and jquery will have a delay to display the data.
$.ajax({url: 'ajax.php', success: function(data){$('#name').text(data.name)}});
When you use jQuery, you ask PHP (or other technology as .NET, ...) to fetch the data from MySQL.
In terms of usability... it depends. Perhaps you want to load your web/application schema and after that use jQuery to load the information (so the web seems to load faster). But, as I said, you will use PHP. The difference is that you can have a PHP file to build the schema and another PHP to retrieve the information.

Categories