我的目的是$suggestion[$ss_count]
成为一个超链接,引导您到 index2.php 并将$suggestion[$ss_count]
in 插入到查询字段中。由于我的查询是通过邮寄方式发送的,我该怎么做?
PHP:
if ($_POST['query'])
{
$query = urlencode($_POST['query']);
$s_count = 0;
$ss_count = 0;
$query = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/'.$query.'?';
$xml = new SimpleXMLIterator(file_get_contents($query));
foreach ($xml -> suggestion as $suggestion[$s_count])
{
$s_count++;
}
if ($s_count > 1)
{
echo ('<h2>Spelling suggestions</h2>');
while ($ss_count <=$s_count)
{
echo ($suggestion[$ss_count].'<br>');
$ss_count++;
}
}
HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Search Attempt</title>
</head>
<body>
<form method="POST" action='safegoogle.php'>
<label for="query">Query</label><br/>
<input name="query" type="text" size="60" maxlength="60" value="" /><br /><br />
<select name ="agg">
<option value="Aggregated">Aggregated</option>
<option value="Non-Aggregated">Non-Aggregated</option>
<option value="Bing">Bing</option>
<option value="Blekko">Blekko</option>
<option value="Faroo">Faroo</option>
</select>
<input name="bt_search" type="submit" value="Search" />
</form>
<h2> Results </h2>
</body>
</html>