Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 动态XML与SQL数据库。如何?_Php_Xml - Fatal编程技术网

Php 动态XML与SQL数据库。如何?

Php 动态XML与SQL数据库。如何?,php,xml,Php,Xml,情况如下: 我有一个图片上传网站。当用户上传照片时,照片id和照片url等详细信息存储在名为photos的表中。为了知道哪个用户上传了哪些照片,我创建了一个名为member\u photos的表,其中包含以下字段,member\u id,photo\u id。要显示图库,我只需将会话id与成员id的会话id进行比较,然后查询照片 我想要的是,照片url不是存储在SQL db上,而是以以下方式存储在XML文件中 <user>Steve</user> <ph

情况如下:

我有一个图片上传网站。当用户上传照片时,照片id和照片url等详细信息存储在名为photos的表中。为了知道哪个用户上传了哪些照片,我创建了一个名为member\u photos的表,其中包含以下字段,member\u id,photo\u id。要显示图库,我只需将会话id与成员id的会话id进行比较,然后查询照片

我想要的是,照片url不是存储在SQL db上,而是以以下方式存储在XML文件中

<user>Steve</user>
      <photourl>http://localhost..</photourl>
      <photourl>http://localhost..</photourl>
      <photourl>http://localhost..</photourl>

<user>John</user>
      <photourl>http://localhost..</photourl>
      <photourl>http://localhost..</photourl>
      <photourl>http://localhost..</photourl>

Steve
http://localhost..
http://localhost..
http://localhost..
约翰
http://localhost..
http://localhost..
http://localhost..
一个用户可以上传多张照片,但一张照片只属于一个用户。一对多关系

我还希望php将数据写入XML文件

现在要为特定用户显示图库,我所做的就是将成员id与会话的成员id进行匹配,然后从数据库中检索照片url

我要做的是从XML文件中检索照片URL,并使用XSLT以表格格式显示它


有人吗?非常感谢您的帮助:-)

如果您想从PHP中读取/写入XML,请尝试类似的库

一旦你进展顺利,有了具体的问题,这个网站上的人会更好地帮助你

此外,如果您设计自己的XML,您将需要

  • 拥有一个包含所有其他元素的顶级元素
  • 将每个用户的数据分组到单个元素中
例如


http://localhost..
http://localhost..
http://localhost..
http://localhost..

为什么要“存储”XML文件?为什么不从db表按需创建它呢?这个问题与XSLT有什么关系?
<users>
  <user id="Steve">
    <photourl>http://localhost..</photourl>
    <photourl>http://localhost..</photourl>
  </user>

  <user id="John">
    <photourl>http://localhost..</photourl>
    <photourl>http://localhost..</photourl>
  </user>
</users>