Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php mysql中显示所选用户的记录_Php_Mysql - Fatal编程技术网

在php mysql中显示所选用户的记录

在php mysql中显示所选用户的记录,php,mysql,Php,Mysql,我试图使用php和mysql在一个表中显示两个表的记录。 我有两张会员和付款表 成员 id | name |..... ---------- 101 | abc |.. 付款表包含 id | uid | amount ---------- 1 | 101 | 1200 我想显示输入编号的记录。我的表格显示所有行。 我只想显示一个数字的记录 这是密码。。 这是第1页,其中用户as输入一个数字,dat编号的记录as显示在第二页 <form method="post" action="rep

我试图使用php和mysql在一个表中显示两个表的记录。 我有两张会员和付款表

成员

id | name |.....
----------
101 | abc |..
付款表包含

id | uid | amount
----------
1 | 101 | 1200
我想显示输入编号的记录。我的表格显示所有行。 我只想显示一个数字的记录

这是密码。。 这是第1页,其中用户as输入一个数字,dat编号的记录as显示在第二页

<form method="post" action="reportdet2.php">
<label type="text" name="name" maxlength="50" size="30" class="label">Enter the Membership Number which You waant to edit</label><br />
<input type="text" name='id' placeholder="enter Membership Number" class="input" size="40"/><br />
<span class="field">(* Required field)</span><br /><br />
<input type="hidden" name='uid' placeholder="" class="input" size="40"/><br />

<input type="submit" name="submit" value="SUBMIT" class="button"><br /><br /><br /><br />
</form>
</body>
</html>

输入您想要编辑的会员编号

(*必填字段)







第2页

    <?php
    mysql_connect("localhost","root","");
    mysql_select_db("anthonys");
    if(isset($_POST['submit']))
    {
    $id= $_POST['id'];

    if( ! ctype_alnum($id) )
      die('invalid id');
    $uid=$_POST['uid'];

    $query="SELECT m.id, m.fathername, m.mothername
    FROM member m JOIN payment p ON m.id = p.uid";



    if(mysql_num_rows($run)>0){
    echo "<script>window.open('reportdet2.php','_self')</script>";
    }

    else {

        echo "<script>alert('Membership No is Invalid!')</script>";
        }
    }
    ?>


<th>No</th>
<th>Name</th>


<th>UID</th>

<th>Amount</th>

</tr>


<?php
$id="";
$id=$_REQUEST["id"];

$uid=$_REQUEST["uid"];
mysql_connect("localhost","root","");
mysql_select_db("anthonys");
$query="SELECT m.id, m.fathername, m.mothername
FROM member m JOIN payment p ON m.id = p.uid";

$run= mysql_query($query);






while($row=mysql_fetch_array($run))
{
$id=$row[0];
$name=$row[1];
$uid=$row[2];

$amount=$row[3];


?>

<tr align='center'>
<td><?php echo $id; ?></td>

<td><?php echo $name; ?></td>
<td><?php echo $uid; ?></td>

<td><?php echo $amount; ?></td>



</tr>
<?php } ?>
</table>

<?php
        $result = mysql_query("SELECT sum(amount) FROM payment") or die(mysql_error());
        while ($rows = mysql_fetch_array($result)) {
    ?>
    <div class="pull-right">
        <div class="span">
            <div class="alert alert-success"><i class="icon-credit-card icon-large"></i>&nbsp;Total:&nbsp;<?php echo $rows['sum(amount)']; ?></div>
        </div>
    </div>
    <?php }
    ?>
</body>
</html>

WHERE m.id=$id
子句添加到SQL查询中,以仅显示与
$id
匹配的记录


请注意,您的(示例)脚本容易受到各种恶劣攻击。。。我不知道您的实际应用是否有安全防范措施等。。如果不是,你可能会想

不要使用mysql。它已被弃用。(我也不知道,但不知何故我怀疑它)它显示同一行两次。