Easily Update Table From Remote File - php

I apologize if I'm missing any details to this question, I really don't know what I need.
I've got a table of the "Top X" of the week that I need to update daily. I want it to be as easy 'in and out' as possible to update.
Ideally I'd like the information taken from a file I can edit and upload to my server and auto-update the table, or something like this.
My list of Top 10 'xyz' is currently static. This means every time the order changes (which could be 20 times a day) I have to manually update the table. Is there a way I can dynamically update my table in accordance to the "official list" on another website?
Is this possible? I'm going to guess they will require PHP, but really haven't gone into too much of it. Any links to help me accomplish this are very much appreciated!

There are many ways to do this. Here are a few.
Just Edit the HTML
Read from a database.
Dynamically load txt file (eg JSON,CSS) via JavaScript.
Dynamically load html file (with just the table) via JavaScript.

Related

How do I permanently change the contents of a div with JavaScript & PHP?

Okay. So I don't have any example code to show, but after doing a bit of research and learning the basics of PHP, I think the answer to my question should be pretty simple.
Here is the scenario, as I would like it to be:
On the homepage there will be several team names, with scores next to them. Like "house-points" in Harry Potter.
Below the score is a small text-field. Below that is a submit button.
The user will put a number in the text-field, press submit, and that number will be added to the team's total score.
NOW. I know how to achieve all of that with JavaScript. Easy. What I want to know IS:
How do I make that new number (the new score total) STAY there. I need to permanently alter the HTML when that submit button is pressed.
All I know is that I need to use PHP. I know the basics of PHP, so whatever the answer is, just throw it at me and I'll figure it out.
Sounds like what you want to do is submitting forms. First drop the JavaScript, you won't need it. What you need is to put your text fields in a form and when you submit you can fetch your values with $_<GET|POST|REQUEST>['<name_of_field>'].
Then you will need to store it somehow. The best way to do it is to use a database like MySQL or MongoDB to store it, but it could be a bit tricky if you are just learning this, so maybe you would like to stick to files. You could do this with INI files and PHP's INI functions.
Lastly you will need to print out the correct values to the website. Now this is easy: Just edit your HTML file to do something like
<?php echo $score['team1']; ?>
for each team after retrieving the correct values at the top or something. (Don't forget to rename the HTML file to .php as well).
Now you should be all set to save your scores. =)
If you mean really permanent you'll have to send it to a database via Ajax (combination of PHP and Javascript). OR write it to a text-document, which is less good.

How can I sort multiple tables i export from an sql database to excel by date?

I have searched for help with this extensively but haven't been able to figure it out. This is my first attempt at asking a question here so please bare with.
I have a project called www.farmathand.com where farmers keep track of their field activities through multiple pre-defined forms and a few dynamic forms. These forms then have an associated date with them to keep a record of when something was done. Here's a screen shot
Farmers have the ability to export all their entered information into an excel file. The problem I am having is figuring out a solution so sort the activities by date. Currently I have simple export code that looks and print data from each table (i.e. each type of activity) then moves on the to the next able. The fields in each table differ as you can see in the image.
Here is a screen shot of an excel file for the above example:
What i would like to be able to do is sort the activities by the date. So in the example in the above image. Line 7 would be at the top or like one should be line 6.
I was wondering if anyone had any suggesting or could guide me to the appropriate reference. The data base is a mysql database. I'm running php scripts currently.
If I understand your question correctly then what you want is to include an ORDER BY clause in your select query to sort the data. More information here:
http://dev.mysql.com/doc//refman/5.0/en/sorting-rows.html

Separate a table in different tabs (HTML, PHP, JavaScript, etc)

Let me start off by saying that this is my first time working with PHP, HTML, JavaScript, and JQuery, so my experience is fairly lacking.
I am helping to build a Web Order Processor, which will display orders, dates, customers, and status. I am pulling orders from our database, and displaying them in a table. the Order Processor is being built in PHP.
Now, I've been asked to separate the table into different tabs, which will be labeled after the possible order statuses we have. Sort of like the tabs at the top of a browser.
My problem is quite a big one: I don't know where to start. I've been searching for a couple hours but I don't think I'm using the correct terminology.
Thank you all in advance. Any help would be appreciated, even if it's just pushing me in the right direction by giving me a couple things to search for.
I would suggest start with this: http://jqueryui.com/demos/tabs/
First make sure your tabs are working with the simple static content
Second upgrade it so every time tab switched, it loads content from the database.
Depending on a tab you can customize request to the server with the status=(NEW,PROCESSES,REFUND ...), and do the query and return a proper data for the tab.
Hope it helps

Store data using a txt file

This question might seem strange but I have been searching for an answer for a long time and I couldn't find any.
Let's suppose you have a blog and this blog has many post entries just like any other blog. Now each post can have simple user comments. No like buttons or any other resource that would require data management. Now the query is: Can I store user comments on a single text file? Each post will be associated to a text file that holds the comments. So, if I have n posts I'll have n text files.
I know I can perfectly do this, but I have never seen it anywhere else and no one is talking about it. For me this seems better than storing all coments from all posts in a single mysql table but I don't know what makes it so bad that no one has implemented it yet.
Storing comments in text files associated with corresponding post? Lest see if it's good idea.
Okay adding new comments easy - write new text to the file. But what about format of your data? CSV? Ok then you would have to parse it before rendering.
Paging. If you have a lot of comments you may consider creating paging navigation for it. It can be done easily, sure. But you would need to open the file and read all the records to extract say 20.
Approve your comments. Someone posted new comment. You place it with pending status. So.. In admin panel you need to find those marked comments and process then accordingly - save or remove. Do you think it's convinient with text files? The same if use decided to remove its comment himself.
Reading files if you have many comments and many posts will be slower the it would be in case of database.
Scalability. One day you deside to extend you comments functionality to let one comment to respond to another. How would you do it with text files? Or example from comments by nico: "In 6 months time, when you will want to add a rating field to the comments... you'll have a big headache. Or, just run a simple ALTER query".
This is just for beggining. Someone may add something.
Well, there are good reasons why this isn't done. I can't possibly name them all, but the first things that come to mind:
Efficiency
Flexibility
Databases are much more efficient and flexible than plain text files. You can index, search and assign keys to individual comments and edit and delete any comments based on their key.
Furthermore, you'd get a huge pile of text files if the blog is quite big. While in itself that's not a problem, if you all save them in one directory, it can grow out of proportion and really increase the access time needed to find and open a specific text file.

How do I create a "todo" list for my web users to tick off?

I'm trying to think of a way to create a list of items that I can display on a webpage that my visitors can tick off, without ever having to log in.
The list may be like so:
[ ] Buy potatoes
[ ] Pickup kids
[x] Drink more water
[ ] Go for a Run
If User A visits the site, and clicks "Drink More Water" I want that to save in a database so that when User B visits, "Drink More Water" is already ticked.
Is there any simple ways to do that:
in PHP?
with Javascript?
or even as a WordPress plugin?
Do you know if there's any existing code around that does this?
TaDa List by 37Signals comes very close, but only allows specific people to tick things off.
Any suggestions would be greatly appreciated.
Thanks
Turgs
If you want to create this yourself you should learn PHP and MySQL (and possibly Javascript (for AJAX)), and HTML and CSS (maybe you already know some of these). After you know these it will become clear how to create this.
You should first learn HTML
then PHP
then MySQL (or any SQL that works with PHP)
then CSS
Then Javascript
We can't really answer your question like this, because it involves big amounts of code. Adn won't really help you if you don't know these languages.
I'll tell you what you need to do, but you're going to have to research most of the things.
You need html to create the list.
You need php to query sql and check if one of them should be checked or not.
Load the page with the data you got from your database server (set the checked ones as checked).
When the user checks one of them you need to store it in the database, so that when another user loads the page he can then get the changes from the database.
Hope this is clear enough.
Just store that information in cookies.
$_COOKIE['ticket'] = 3;
when he visit the page next time just check if $_COOKIE['ticket'] is not empty.
You could do this kind of thing with a file instead of a database. So when the user checks off a box, it loads a PHP file that reads an XML file with the tasks and check-status, then re-writes that file with the modified value.
It's quick, dirty, and doesn't need a database.
You could use a REST like url that defines a list. i.e.: http://ticklist.com/list/145
People can share this common list.
Something like the logic of http://friendpaste.comTo let people share and edit source codes.

Categories