【发布时间】:2015-12-16 11:34:09
【问题描述】:
我有一个 PHP CRUD 系统,如果用户可以选择一个选项,我希望这些选项是带有目标的外部超链接。我无法确定可以将两个链接放在哪里,我的代码可以这样做吗?
index.php
<td><?php echo $row['usertype'] ?></td>
create.php
<div class="form-group">
<label for="gd">User Type</label>
<select class="form-control" id="gd" name="gd">
<option>Administrator</option>
<option>NetMan</option>
</select>
</div>
update.php
<?php
$usertypes = array('Administrator' => 'Administrator', 'NetMan' => 'NetMan');
$selcted_usertype = !empty($row['usertype']) ? $row['usertype'] : "";
?>
<label for="gd">User Type</label>
<select class="form-control" id="gd" name="gd">
<?php
foreach ($usertypes as $user_type_val => $usertype_txt) {
$selected = ($user_type_val == $selcted_usertype) ? "selected='selected'" : "";
?>
<option <?php echo $selected; ?> value="<?php echo $user_type_val; ?>"><?php echo $usertype_txt; ?></option>
<?php }
?>
【问题讨论】:
-
请详细说明您的问题。如果用户更改下拉值,您想重定向吗?
-
不抱歉,当用户在索引页面上看到表格时,我希望文本是超链接,所以基本上这两个选项都是外部链接
-
最终我将有 10 个选项,都将转到单独的外部站点
-
那你为什么要使用选择标签。只需使用锚标签
-
选择转到我的数据库,锚不会工作吗?