如何在输入文本中输入姓名,电子邮件,用户名或D.O.B时显示数据? [英] How to display the data when name, email, username or D.O.B is entered in the input text?
本文介绍了如何在输入文本中输入姓名,电子邮件,用户名或D.O.B时显示数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Quote:我有一个欢迎页面,其中包含已注册的所有用户数据。在我的欢迎页面中,他们是输入字段,所以当我输入任何人的姓名,用户名,电子邮件,DOB说pavan或pavan1994@gamil.com,然后所有行与此输入的数据匹配,只显示那些行。
我的尝试:
< pre><?php
session_start();
if(!isset($ _ SESSION ['id'])){
header('location:login.php');
}
?>
<!DOCTYPE html>
< html>
< body>
<?php
include_once'connect.php';
$ query = mysqli_query($ mysqli,select * from`users` where userid ='。$ _ SESSION ['id']。');
$ row = mysqli_fetch_array($ query);
echo'Welcome - '。$ row ['username'];
?>
< br>
< a href =logout.php>退出< / a>
< br>
<?php
// include_once'connect.php';
$ result = mysqli_query($ mysqli,SELECT * FROM users);
echo< table border ='1'>
< tr>
< th> User_ID< / th>
< th>名称< / th>
< th>用户名< / th>
< th>电子邮件< / th>
< th>部门< / th>
< th> Date_of_birth< ; / th>
< th>年龄< / th>
< th>图片< / th>
< th>行动< / th>
< th> ;行动< / th>
< / tr>;
while($ row = mysqli_fetch_array($ result))
{
echo< tr>;
echo< td> 。 $ row ['userid']。 < / TD> 中;
echo< td> 。 $ row ['name']。 < / TD> 中;
echo< td> 。 $ row ['username']。 < / TD> 中;
echo< td> 。 $ row ['email']。 < / TD> 中;
echo< td> 。 $ row ['department']。 < / TD> 中;
echo< td> 。 $ row ['Date_of_birth']。 < / TD> 中;
echo< td> 。 $ row ['age']。 < / TD> 中;
echo< td>< img alt ='image'style ='width:100px; height:50px;'src ='upload /\".$ row ['filename']。'>< ; / TD>中;
echo< td>< a href ='editform.php?id =。 $ row ['userid']。 >编辑< / A>< / TD>中;
echo< td>< a href ='deleteform.php?id =。 $ row ['userid']。 >删除< / A>< / TD>中;
echo< / tr>;
}
echo< / table>;
?>
<?php
// include_once'connect.php';
if(isset($ _ POST [happy])){
if(empty($ _ POST [happy])){// not empty name
echo'< br> ;';
echo没有输入信件;
} else {
$ name = $ _POST [happy];
$ id = $ _GET ['id'];
$ sql =SELECT * FROM`users` WHERE userid ='$ id';
$ result = mysqli_query($ mysqli,$ sql);
$ row = mysqli_fetch_array($ result);
$ sql =从'users`选择名称,用户名,电子邮件,Date_of_birth;;
if(mysqli_query($ mysqli,$ sql)=== TRUE){
print_r($ id);
}其他{
echo'找不到记录';
}
}
}
?>
< form method =post>
< br>
搜索:< input type =textname =happy>< br>< br>
< input type =submitvalue =提交>
< / form>
< / body>
< / html>
解决方案
< blockquote> _SESSION ['id'])){
header('location:login.php');
}
?>
<!DOCTYPE html>
< html>
< body>
<?php
include_once'connect.php';
query = mysqli_query(
mysqli,select *来自`users`,其中userid ='。
Quote:I have a welcome page with all the users data who have registered. In my welcome page their is an input field, so when I enter anyone's name,username,email,D.O.B say pavan or pavan1994@gamil.com , then all the row matches with this entered data, only those row should be displayed.
What I have tried:
<pre><?php session_start(); if (!isset($_SESSION['id'])) { header('location:login.php'); } ?> <!DOCTYPE html> <html> <body> <?php include_once 'connect.php'; $query=mysqli_query($mysqli,"select * from `users` where userid='".$_SESSION['id']."'"); $row=mysqli_fetch_array($query); echo 'Welcome - '.$row['username']; ?> <br> <a href="logout.php">Logout</a> <br> <?php //include_once 'connect.php'; $result = mysqli_query($mysqli,"SELECT * FROM users"); echo "<table border='1'> <tr> <th>User_ID</th> <th>Name</th> <th>Username</th> <th>E-mail</th> <th>Department</th> <th>Date_of_birth</th> <th>Age</th> <th>Image</th> <th>Action</th> <th>Action</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['userid'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['department'] . "</td>"; echo "<td>" . $row['Date_of_birth'] . "</td>"; echo "<td>" . $row['age'] . "</td>"; echo "<td><img alt='image' style='width:100px;height:50px;' src='upload/".$row['filename']."'></td>"; echo "<td> <a href='editform.php?id=" . $row['userid'] . "'>Edit</a></td>"; echo "<td> <a href='deleteform.php?id=" . $row['userid'] . "'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; ?> <?php //include_once 'connect.php'; if(isset($_POST["happy"])){ if(empty($_POST["happy"])){ //not empty name echo '<br>'; echo "No letter entered"; }else { $name = $_POST["happy"]; $id = $_GET['id']; $sql = "SELECT * FROM `users` WHERE userid='$id'"; $result = mysqli_query($mysqli, $sql); $row = mysqli_fetch_array($result); $sql="select name, username, email, Date_of_birth from `users`;"; if (mysqli_query($mysqli, $sql) === TRUE) { print_r($id); }else { echo 'No record found'; } } } ?> <form method="post"> <br> Search: <input type="text" name="happy"><br><br> <input type="submit" value="Submit"> </form> </body> </html>
解决方案
_SESSION['id'])) { header('location:login.php'); } ?> <!DOCTYPE html> <html> <body> <?php include_once 'connect.php';
query=mysqli_query(
mysqli,"select * from `users` where userid='".
这篇关于如何在输入文本中输入姓名,电子邮件,用户名或D.O.B时显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文