How should I go about this? - php

I have a MySQL Database of more or less 100 teachers, their names, and their phone numbers, stored in tables based upon their department at the school. I'm creating an iPhone app, and I've found that UITableViews and all the work that comes with it is just too time consuming and too confusing. Instead, I've been trying to create a web page on my server that loads all the data from MySQL and displays it using HTML, PHP, jQuery, and jQTouch for formatting.
My concept is that the separators will be by department, and the staff will be sorted alphabetically under each department. On the main page, each person's name will be clickable so they can go to ANOTHER page listing their name, email address, and telephone number, all linked so that the user can tap on the email or number and immediately email or call that person, respectively.
HOWEVER, I am completely at a loss for how I should start. Can anyone point me in the right direction for displaying the data? Am I going about it wrong in using PHP? Should I opt for something COMPLETELY different?

PHP to manage the database interaction and generate HTML is fine. There are heaps of tutorials on how to do that (e.g. http://www.w3schools.com/PHP/php_mysql_intro.asp) How to make it look nice is beyond the scope of this answer, and I'd recommend you search for table/CSS examples to get some ideas of what looks good and how they're implemented. If you need interactivity such as expanding rows or changing colors, then jQuery would be an appropriate next step, though you certainly don't need more than HTML + CSS for a nice looking table representation.
What I don't know about is the auto email/call functionality you're after, and whether you can get that "for free" from whatever is rendering the HTML. That's iPhone specific, not PHP/jQuery/etc... And I'd second Alex's advice that if UITableView is the right tool for the job then you will definitely be better off in the long run just buckling down and learning it. (And going through that will probably make pickup up other parts of the API much easier to boot.)

Instead of loading my PHP in my <body>, I created a function that retrieved the data via mysql_fetch_assoc(), which added all the information and created each individual div of data AS WELL AS injecting a <script> to $.append() the list item content for each item retrieved via the mysql_fetch_assoc(). Thanks for the responses anyway!

Related

Search On Website using php variable - DOM Parsing

I want to search on website pragmatically using PHP like as we search on website manually, enter query on search box press search and result came out.
Suppose I want to search on this website by products names or model number that are stored in my csv file.
if the products number or model number match with website data then result page should be displayed ..
I search on below question but not able to implement.
Creating a 'robot' to fill form with some pages in
Autofill a form of another website and send it
Please let me know how we can do this PHP ..
Thanks
You want to create a “crawler” for websites.
There are some things to consider first:
You code will never be generic. Each site has proper structure and you can not assume any thing (Example: craigslist “encode” emails with a simple method)
You need to select an objective (Emails ? Items information ? Links ?)
PHP is by far one of the worst languages to do that.
I’ll suggest using C# and the library called AgilityHtmlPack. It allows you to parse HTML pages as XML documents (So you can do XPath expressions and more to retrieve information).
It surely can be done in PHP, but I think it will take at least 10x time in php compared to c#.

PHP/ajax table and Google results

A couple years ago I had a client with a limited budget and a short deadline who wanted a sortable searchable table of their parts inventory online - at the time they had only an excel spreadsheet. I created a database, then I just used Script Artist (because I had it) to do the front end. It all works great and he's been happy with it, except now we'd like to make sure that Google can actually find all 17,000+ parts they have available and not just the first 25.
The page where the inventory is located is just www.thesite.com/inventory.php and the url remains the same no matter what page you're on.
I've been looking around at different options, using pushState vs html snapshots, and I'm not sure what would be the best option or if I can even do anything with the current Script Artist setup or if I should just pitch the whole thing. I'd really rather not have to start over since he still doesn't have much of a budget, so if anyone could give me any input that would be helpful. Thanks.

Make paragraph of text an editable textarea on click

I have an about box on a profile page I'm working on (see below). Now that area shown by the textarea will have a PHP variable (about user column) produced in the space.
What I want to do is when a user clicks edit the paragraph content produced becomes an editable <textarea> which I can then save and it will write the new data to my PostGreSQL database and instantly show the new edit.
Basically I'm looking for a dynamically editable paragraph/textarea combo which will automatically update the database storing the original textual data in an about user column.
I have researched many JQuery examples like this on jsfiddle - http://jsfiddle.net/BenjaminRH/467S5/ but that doesn't have the database functionality I am looking for.
In essence, the HTML5 ContentEditable attribute could be perfect here.
This won't automatically update any databases, or anything for that matter, but nor will any other control that isn't some kind of composite made specifically for (and even genericised to handle) certain database types and scenarios and frameworks etc.
Therefore, in order to get this (a control that does it all) you're likely going to need to hunt down a third party product - there may be a free one (I've not seen one for the likes of PHP or ASP.NET or other major frameworks, and frankly I'm glad), or you may be stuck with having to buy one. As expected, I personally can't vouch for any, and wouldn't recommend such a plug n' play control anyway.
But, as per my first suggestion, there's half the task done - just write the code-behind in a reusable class and hook it up some how.

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

From PHP to jQuery?

So I've been struggling with finding a simple and efficient solution for the following problem. The solution I have now works, but since I'm working on this for the sake of learning ...
So, the case:
I have a PHP page which gets loads of persons from a DB, then sorts them and finally puts all persons
in a html list. What I'm after is a elegant solution to edit these persons by clicking on them from the list. I've found a jQuery pop-up solution that looks brilliant, but not so easy to use for beginners.
Since there are several persons I need to produce a different pop-up window depending
on which person is clicked. The problem is that the jQuery pop-up is based on the html being pre made, which is obviously hard since I don't know which person the user will click.
The best I've come up with so far is sending a GET -variable to the page with the person list, which then checks if there is a valid variable from GET and produces the HTML for the clicked person based on the id/variable. The problem with this is that I have to essentially run the same query twice; once to get all persons and once to get the clicked person. It isn't a big problem, it's more that since I'm new with jQuery I'm wondering if there is a simpler/better solution. I'm not really sure what jQuery can and can't do.
Thanks for any replies.
I'd start by asking why you don't ask the database to sort/ORDER the values before sending them back to your PHP page? It's well-suited for that sort of thing.
You could know which person was clicked if you added the database id to each element and passed that around. Have jQuery add it to the DOM element for each row in the HTML table.
kinda the standard way would be to pass the persons as JSON, and use the jquery templating system to build the forms. Of course this could be a bit daunting to a beginner, but its not that hard.

Categories