在PHP问题的持久性数据 [英] persistent data in php question

查看:127
本文介绍了在PHP问题的持久性数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定香港专业教育学院的书面使用jQuery和Ajax这个整洁的JavaScript的东西。所有基于一个div有一个属性,它可以让你写在div里面的想法。 (CONTENTEDITABLE = TRUE)。我认为这将是冷静地做出聊天室类型的事情出来,和圣牛它做一些很酷的东西(*),但我有一个问题。

OK Ive written this neat javascript 'thing' using jquery and ajax. Its all based on the idea that a div has an attribute that lets you write inside the div. (contenteditable=true). I thought it would be cool to make a chatroom type thing out of it, and holy cow its doing some cool stuff(*), but I have an issue.

使用AJAX我张贴到一个PHP页面,是以发布的数据(X,Y,文字,ID)和它填充到类JSON对象。如果没有写入数据库(矫枉过正我认为),我怎样才能使这个数据持续?看到这个问题? :在PHP页面的变量基本上是蒸汽后,页面已经跑了,所以要retrieveNewJSON()我的JavaScript调用Ajax会发现什么

Using ajax I post to a php page that takes the posted data (x,y, text, id) and stuffs it into a JSON-like object. Without writing to a database (overkill I think), how can I make this data persist? See the problem? : The variables in a php page are essentially vapor after the page has ran, so my javascript ajax call to retrieveNewJSON() would find nothing.

*使用jQuery效果和设置颜色我都可变放置文本滚动和蒸发,矩阵式的,例如。此外,光标被放置在用户点击股利。

*using jquery effects and setting colors I have variably placed text that scrolls and evaporates, matrix style, for example. Also, a cursor is placed in the div where the user clicks.

推荐答案

您需要的地方存储数据。如果你不希望使用一个完全成熟的数据库,你可以将它们存储在平面文件(即:TXT)和使用PHP的文件功能来处理这些文件。

You have to store the data somewhere. If you don't want to use a full blown database you can store them in flat files (ie: txt) and use PHP's file functions to handle the files.

当然,这也不是很可扩展的,我强烈建议使用一个数据库,如果你打算使用这个有很多。

Of course this is not very scalable, and I'd strongly recommend using a database if you are going to be using this a lot.

这篇关于在PHP问题的持久性数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆