大家好,我认识的使用 MySQL 进行此搜索的每个人LIKE '"%% $ _POST [" txtbuscar "]%%"'
,我现在正在使用 XML 执行此操作。我需要想出一个输入 txtbuscar。
下面的脚本我已经设法列出和分页,并搜索最重要的单词,但我相信这是一些东西,但不起作用,你能帮帮我吗?
XML
<listaccts>
<acct>
<disklimit>100M</disklimit>
<diskused>100M</diskused>
<domain>dominio.com.br</domain>
<ip>123.124.125.126</ip>
<user>Fulano</user>
<plan>Plano1</plan>
</acct>
<acct>
<disklimit>200M</disklimit>
<diskused>200</diskused>
<domain>dominio.com.br</domain>
<ip>123.124.125.126</ip>
<user>Fulano2</user>
<plan>Plano2</plan>
</acct>
</listaccts>
PHP
$accounts = $xmlapi->listaccts();
$xml = simplexml_load_string($accounts);
if ($_POST["txtBuscar"] == "ligar") {
$busc = $_POST["buscarURL"];
foreach ($xml->xpath('//acct') as $acct) {
$minhaArray = $xml->xpath('//user[.>$busc]');
$minhaArray = array();
foreach ($xml->acct as $acct) {
$minhaArray[] = array(
'domain' => (string)$acct->domain,
'user' => (string)$acct->user,
'ip' => (string)$acct->ip,
'disklimit' => (string)$acct->disklimit,
'diskused' => (string)$acct->diskused,
'plan' => (string)$acct->plan);
}
}
HTML
<form id="formBuscaClienteUrl" name="formBuscaClienteUrl" method="post" action="" class="sky-form" onsubmit="return false">
<input name="txtBuscar" type="hidden" value="ligar" />
<script language="javascript">document.formBuscaClienteUrl.buscarURL.focus();</script>
<table width="100%" cellspacing="0" cellpadding="5">
<tr>
<td width="95%" style="padding-left:10px;">
<input name="buscarURL" type="text"/>
</td>
<td width="5%"><button style="padding-left:10px;" type="submit" onclick="buscar('formBuscaClienteUrl')" class="button" >Localizar</button></td>
</tr>
</table>
</form>
//========================没关系==============
我做了一些调整,现在就起来了,以防万一。谢谢
$busc=$_POST["buscarURL"];
$expression = sprintf("/*/acct[contains(user, '$busc')]", $_POST["buscarURL"]);
$result = $xml->xpath($expression);
$minhaArray = array();
foreach($result as $account){
$minhaArray[] = array(
'domain'=>(string)$account->domain,
'user'=>(string)$account->user,
'ip'=>(string)$account->ip,
'disklimit'=>(string)$account->disklimit,
'diskused'=>(string)$account->diskused,
'plan'=>(string)$account->plan,
);
}