在我的模式窗口中,我想获取数据行的ID字段,并在选择的MYSQL的变量中使用此ID。像这样:
$id= $row["id"];
$query = "SELECT * FROM storage WHERE id='$id'";
如果我这样做:
$id="<input type='text' id='id' name='id' />";
我可以显示此ID,但不能用作模态中的变量php。
答案 0 :(得分:0)
尝试一下...
'operator <<' is ambiguous
could be 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<<void>(std::nullptr_t)'
or 'std::basic_ostream<char,std::char_traits<char>> &testing::internal2::operator <<<char,std::char_traits<char>,T>(std::basic_ostream<char,std::char_traits<char>> &,const T &)'
答案 1 :(得分:0)
嗨,如果您在MySQL的同一页面上使用此模式,请咨询您:
<input type="text" id="id" name="id" value = value="<?php echo $id; ?>" />
希望有帮助
答案 2 :(得分:0)
这是我的代码的一部分:
<!-- MODAL -->
<div class="modal fade" id="editor-modal">
<div class="modal-dialog" role="document">
<form class="modal-content form-horizontal" id="editor">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
<h4 class="modal-title" id="editor-title">Add</h4>
</div>
<div class="modal-body">
<input type="number" id="id" name="id" readonly/>
我的问题从这里开始。如何在选择SQL中使用行ID?
<?php // I get a field in array. ex (1,6,8,) which are the id of the selected places coming from another base.
$id = ???
$query = "SELECT * FROM storage_0 WHERE id='id'";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($result))
{
$exp_string = $row["select_type"];
$exp_arr = explode(',', $exp_string);
for ($i = 0;$i < count($exp_arr);$i++)
{
$val['value_' . $i] = $exp_arr[$i];
}
}
?>
之后,我可以在模式中显示所选地点的列表。
<input type="hidden" id="id" name="id" class="hidden"/>
<div class="form-group">
<label for="type" class="col-sm-3 control-label">Types<span style="padding-left:5px;"><a title="Ajouter un Type" href="../type/editing.php?item=0"><i class="fa fa-edit fa-1x"></i></a></span></label>
<div class="col-sm-9">
<?PHP
$requete = $pdo->prepare('
SELECT id, type
FROM stock_type
WHERE del = 0
ORDER BY id ASC ;');
$requete->execute();
$datas = $requete->fetchAll();
foreach ($datas as $data)
{
if (in_array(intval($data->id) , $val))
{$selected = "checked";}else{$selected = "";}
?>
<span id="results"></span>
<label class="checkbox-inline">
<input type="checkbox" name="select_type[]" id="select_type" value="<?php echo $data->id; ?>" <?php echo $selected; ?>><?php echo $data->type; ?>
</label>
<?php } ?>
<!--...-->