我有一个表单,我需要从用户那里获取i/p.表格分为两部分:左侧和右侧
在左侧部分,值将从用户获取,就像任何普通表格一样.右侧部分将包含将从数据库动态生成的项目列表,每个项目还将具有+按钮,用于添加该特定产品的数量放置的前面下面给出了视图
如您所见,整个页面有一个提交按钮,所以我希望用户填写整个页面(填写左侧的字段,并在右侧输入任意数量的产品的数量)然后单击提交按钮整个页面值保存在数据库中.
<form method="post" action"save.php">
<!--Front end code for left part-->
<label>Name:</label>
<input type="text" name="name" value="" />
</div>
<div class="span3" style="margin-left:-10px;">
<label>Number:</label>
<input type="text" name="number" value="" />
</div>
<div class="span6">
<div class="span3" >
<label>Address:</label>
<textarea name="address"></textarea>
</div>
</div>
<!--Front end code for right part-->
<table class="table table-striped table-bordered">
<tbody>
<?php
$sql=" SELECT * from menu";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_assoc($result))
{?>
<tr>
<td> <? echo $row['dish']; ?></td>
<td class="td-actions">
<input type="text" name="quantity[]" />
<input type='hidden' …Run Code Online (Sandbox Code Playgroud) 我有这段代码,我希望得到一个包含所有值的单个数组.
$sql = "SELECT * FROM interest where interest='".$interest."' and userid!='".$myuserid."'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$userid = $row["userid"];
if($searchtype == 'both')
{
$sql2 = "SELECT * FROM register where id='".$userid."' and discover = 'on' and id!='".$myuserid."'";
$result2 = mysqli_query($conn, $sql2);
if (mysqli_num_rows($result2) > 0)
{
while($row2 = mysqli_fetch_assoc($result2))
{
echo "<pre>";
print_r($row2);
echo "</pre>";
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的o/p是这样的
Array
(
[id] => 1
[email] => A1
[username] =>B1
[password] …Run Code Online (Sandbox Code Playgroud) 我从以下代码中获取数据库中的数据
$sql = "SELECT id FROM vendor where subserviceid='".$subserviceid."'";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_assoc($result))
{
$finalvendorid[]=$row;
}
echo "<pre>";
print_r($finalvendorid);
echo "</pre>";
}
Run Code Online (Sandbox Code Playgroud)
我从上面的代码得到的数组是这样的
Array
(
[0] => Array
(
[id] => 9
)
)
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何更改此数组,以便我得到这样的上述数组
Array
(
[0] => Array
(
[vendorid] => 9
)
)
Run Code Online (Sandbox Code Playgroud)