我的用户数据库中有两个表.
第一个表包含用户唯一ID,名称,联系人号码和其他个人信息.
第二个表包含来自第一个表的用户的唯一ID以及设备信息,例如他的第一个机器号,第二个机器号以及许多其他.
我的表没有2结构是..
在报告页面上,我使用此表格以表格形式显示所有信息
$sql = "SELECT e.* ,d.* FROM emitra_basic As e INNER JOIN emitra_device as d ON d.uid=e.uid";
$result = $conn->query($sql);
if ($result->num_rows>0) {?>
<table ><tr><td> Uid</td><td> Name</td>
<td> Micro Atm</td>.......and all column of both tables </tr>
<?php while($row = $result->fetch_array()) {
echo "<td>". $row['uid']. "</td>";
echo "<td>". wordwrap($row['name'],15,"\n",1). "</td>"; ....and all
} echo "</table>";
Run Code Online (Sandbox Code Playgroud)
它工作正常.但我想展示一份定制报告.这意味着我想为表字段的用户提供复选框/单选按钮.如果他选择字段使用复选框,则其仅显示选中复选框/单选按钮的那些值.它喜欢用户选择三个复选框/单选按钮,如Uid,name,m_atm.它仅显示来自两个表的三列的详细信息,并相应地显示这些列.
我想阅读 RSS 提要并存储它。为此我正在使用:-
<?php
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
$xml = simplexml_load_string($homepage);
echo '<pre>';
print_r($xml);
?>
Run Code Online (Sandbox Code Playgroud)
但首先我想检查一下
1.URL是否有效,即其响应时间是否为
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
Run Code Online (Sandbox Code Playgroud)
不到1分钟且url地址正确
2.然后检查文件(http://www.forbes.com/news/index.xml)是否有有效的XML数据。如果 XML 有效,则显示响应时间,否则显示错误。
我的问题的答案:
谢谢大家的帮助和建议,我解决了这个问题。为此我写了这段代码
<?php
// function() for valid XML or not
function XmlIsWellFormed($xmlContent, $message) {
libxml_use_internal_errors(true);
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadXML($xmlContent);
$errors = libxml_get_errors();
if (empty($errors))
{
return true;
}
$error = $errors[ 0 ];
if ($error->level < 3)
{
return true;
}
$lines = explode("r", $xmlContent);
$line = $lines[($error->line)-1];
$message = $error->message . ' at line …Run Code Online (Sandbox Code Playgroud) 我正在使用简单的代码阅读RSS订阅源:
<?php
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
$movies = new SimpleXMLElement($homepage);
echo '<pre>';
print_r($movies);
?>
Run Code Online (Sandbox Code Playgroud)
和输出如下:SimpleXMLElement Object([@attributes] => Array([version] => 2.0)
[channel] => SimpleXMLElement Object
(
[title] => SimpleXMLElement Object
(
)
[link] => SimpleXMLElement Object
(
)
[description] => SimpleXMLElement Object
(
)
[language] => en-us
[copyright] => Copyright 2009 Forbes.com LLC
[item] => Array
(
[0] => SimpleXMLElement Object
(
[title] => SimpleXMLElement Object
(
)
[link] => SimpleXMLElement Object
(
)
[author] => SimpleXMLElement Object
(
)
[pubDate] => …Run Code Online (Sandbox Code Playgroud)