<form method="POST" action="include/crud.php" enctype="multipart/form-data" >
<?php
foreach (LoadAnouncements() as $value){
/*echo "<div id='bb'></div>";*/
echo "<hr/>";
echo $value['searchresultwhat'];
echo "<br/>\n";
echo $value['searchresultwhen'];
echo "<br/>\n";
echo $value['searchresultwhere'];
echo "<hr/>";
/*echo "<div id='bb'></div>";*/
}
?>
</form>
我有这个表单显示echo有一种方法可以在此echo中添加属性name
,以便我可以用它来查询数据库吗?如果将属性设置为echo是可能的,我会搜索想法,但我还没有发现任何有任何建议值得赞赏
答案 0 :(得分:0)
你在看吗?
<input type="text" name="searchresultwhat[]" value="<?php echo $value['searchresultwhat']; ?>" />
<input type="text" name="searchresultwhen[]" value="<?php echo $value['searchresultwhen']; ?>" />
<input type="text" name="searchresultwhere[]" value="<?php echo $value['searchresultwhere']; ?>" />
被修改
<?php
echo '<table>';
echo '<tr><th>What </th><th> When</th><th> Where</th><tr>';
foreach (LoadAnouncements() as $value){
echo "<tr><td><a href='anotherPage.php?searchresultwhat=".$value['searchresultwhat']."&searchresultwhen=".$value['searchresultwhat']."&searchresultwhere=".$value['searchresultwhat'].">".$value['searchresultwhat']."</a></td>
<td><a href='anotherPage.php?searchresultwhat=".$value['searchresultwhat']."&searchresultwhen=".$value['searchresultwhat']."&searchresultwhere=".$value['searchresultwhat'].">"$value['searchresultwhen']."</a></td>
<td><a href='anotherPage.php?searchresultwhat=".$value['searchresultwhat']."&searchresultwhen=".$value['searchresultwhat']."&searchresultwhere=".$value['searchresultwhere'].">".$value['searchresultwhere']."</a></td>
</tr>";
}
echo '</table>';
?>
答案 1 :(得分:0)
您想在PHP中为特定值添加属性吗?但你不能这样做,因为$value['searchresultwhat']
和其他类似的是简单的字符串 - 按原样!他们不能自己发送分离的数据(或属性)
修改强>
您可以使用数组发送有关特定值的分离数据:
$value['searchresultwhat'] = array("name", "value");
$value['searchresultwhen'] = array("name2", "2014-09-01");
$value['searchresultwhere'] = array("name3", "kittens");
echo $value['searchresultwhat'][0] . " is " . $value['searchresultwhat'][1];
echo $value['searchresultwhen'][0] . " = " . $value['searchresultwhen'][1];
echo $value['searchresultwhere'][0] . " has " . $value['searchresultwhere'][1];