PHP MySQL超链接来自所选内容
我有一个PHP CRUD系统,用户可以选择一个选项,我希望该选项是外部超链接与目标。我不知道我可以把这两个链接放在哪里,我的代码可以这样做吗 index.phpPHP MySQL超链接来自所选内容,php,mysql,hyperlink,crud,Php,Mysql,Hyperlink,Crud,我有一个PHP CRUD系统,用户可以选择一个选项,我希望该选项是外部超链接与目标。我不知道我可以把这两个链接放在哪里,我的代码可以这样做吗 index.php <td><?php echo $row['usertype'] ?></td> <div class="form-group"> <label for="gd">User Type</label> <select class="form-control" i
<td><?php echo $row['usertype'] ?></td>
<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>
<?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 }
?>
create.php
<td><?php echo $row['usertype'] ?></td>
<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>
<?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 }
?>
用户类型
管理员
网人
update.php
<td><?php echo $row['usertype'] ?></td>
<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>
<?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 }
?>
用户类型
如果我理解正确,你想要一个下拉菜单,当你点击一个选项,它会带你到一个外部网站?如果是这样,这可以完成工作:
<select>
<option title="google.co.uk" onclick="location.href='http://example.com'">Administrator</option>
<option title="bbc.co.uk" onclick="location.href='http://example.com'">NetMan</option>
</select>
管理员
网人
请详细说明您的问题。如果用户更改下拉列表值,是否要重定向?不,对不起,当用户在索引页上看到表时,我希望文本是超链接,因此基本上这两个选项都是外部链接。实际上,我有10个选项,所有选项都将分开外部站点。为什么要使用选择标记。只需使用anchor标记选择进入我的数据库,anchor将不起作用,是吗?不,这是我的示例,基本上当他们单击netman时,我希望它显示为google.co.uk,管理员显示为bbc.co.uk,所以当用户单击名称时,它必须显示为google.co.uk或bbc.co.uk的内容?不,仍然要说相同的名称,netman和管理员,我只希望这些名称是外部超链接。如果不想在选择菜单中放置超链接,你可以使用我之前说过的方法。这里有一个JSFIDLE:当你将鼠标悬停在名称上时,它会显示它将要访问的站点,如果你单击,它会将你重定向到该站点。