我该怎么办?
我有一个 MySQL 数据库,其中包含大约 100 名教师、他们的姓名和电话号码,根据他们在学校的部门存储在表中。我正在创建一个 iPhone 应用程序,我发现 UITableViews 及其附带的所有工作太耗时且太混乱。相反,我一直尝试在我的服务器上创建一个网页,从 MySQL 加载所有数据,并使用 HTML、PHP、jQuery 和 jQTouch 进行格式化显示它。
我的想法是,分隔符将按部门划分,并且工作人员将按每个部门的字母顺序排序。在主页上,每个人的名字都可以点击,这样他们就可以转到另一个页面,列出他们的姓名、电子邮件地址和电话号码,所有这些都链接起来,以便用户可以点击电子邮件或号码,然后立即向该人发送电子邮件或打电话,分别。
然而,我完全不知道应该如何开始。谁能指出我显示数据的正确方向?我使用 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHP 可以管理数据库交互并生成 HTML。有大量关于如何执行此操作的教程(例如 http://www.w3schools.com/ PHP/php_mysql_intro.asp)如何让它看起来漂亮超出了这个答案的范围,我建议您搜索表/CSS示例以获取一些关于什么看起来不错以及它们如何实现的想法。如果您需要交互性,例如扩展行或更改颜色,那么 jQuery 将是合适的下一步,尽管您当然不需要 HTML + CSS 来获得漂亮的表格表示。
我不知道的是您想要的自动电子邮件/呼叫功能,以及您是否可以从渲染 HTML 的任何内容中“免费”获得该功能。这是 iPhone 特有的,而不是 PHP/jQuery/等等...我赞同 Alex 的建议,如果 UITableView 是适合这项工作的工具,那么从长远来看,只要认真学习它,你肯定会过得更好。 (完成这个过程可能会让 API 的其他部分更容易启动。)
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.)
我没有在
中加载 PHP,而是创建了一个通过
mysql_fetch_assoc()
检索数据的函数,该函数添加了所有信息并创建了每个单独的div
数据以及将注入到
$.append()
通过检索的每个项目的列表项目内容mysql_fetch_assoc()。无论如何,感谢您的回复!
Instead of loading my PHP in my
<body>
, I created a function that retrieved the data viamysql_fetch_assoc()
, which added all the information and created each individualdiv
of data AS WELL AS injecting a<script>
to$.append()
the list item content for each item retrieved via themysql_fetch_assoc()
. Thanks for the responses anyway!