简体   繁体   English

我如何在使用while循环在php中创建的表下方显示消息

[英]how can i display message below a table created using while loop in php

this is the display page.i want to dislay message after while loop gets over below the table .the code below displays the message beside the table. 这是显示页面。我想在while循环移到表格下方后分配消息。下面的代码在表格旁边显示消息。 I want to echo a message such as "data fetched sucessfully" below the table 我想在表格下方回显一条消息,例如“数据已成功获取”

<?php
session_start();
$con=mysql_connect("localhost","root","") or die("Could not Connect");
$db=mysql_select_db("practice",$con);
if($_SESSION['user']=="")
{
    header("location:login.php");

}
if(isset($_GET['status']))
{
    $status=$_GET['status'];
    if($status==sucess)
    {
        echo "<h2>Details Updated Succesfully....!!</h2>";
    }
}
echo "Welcome ".$_SESSION['user'];
echo "<br>";
$page=$_GET['page'];
if($page=="" || $page=="1")
{
$page1=0;
}
else
{

  $page1=($page*4)-4;
  }
$query="SELECT * FROM `details` LIMIT $page1,4";
$result=mysql_query($query,$con);
$numrows=mysql_num_rows($result);
if($numrows>0)
{?>
<table  align="left"  border="1" >
<thead>
<tr>
  <th>NAME</th>
  <th>USERNAME</th>
  <th>PASSWORD</th>
  <th>Hobbies</th>
  <th>E-MAIL</th>
  <th>GENDER</th>
  <th>CONTACT</th>
  </thead>
  <tbody>
 <?php
  while($row=mysql_fetch_array($result))
 {?>
 <tr>
  <td><?php  echo $row['name'];?></td>
  <td><?php  echo $row['username'];?></td>
  <td><?php  echo $row['password'];?></td>
   <td><?php echo $row['hobbies'];?></td>
  <td><?php  echo $row['email'];?></td>
  <td><?php  echo $row['gender'];?></td>
  <td><?php  echo $row['contact'];?></td>
  <td><a href="update.php?id=<?php echo $row['id'];?>">Update</a></td>
  <td><a href="delete.php?id=<?php echo $row['id'];?>">Delete</a></td>
 </tr>
<?php

}
echo "data fetched sucessfully";


  ?> 
</tbody>
</table>
</br></br></br></br></br></br></br>
  <?php
$query1="SELECT * FROM `details`";
$result=mysql_query($query1,$con);
$count=mysql_num_rows($result);
$a=ceil($count/4);

for($b=1;$b<=$a;$b++)
{
?><a href="welcome.php?page=<?php echo $b; ?>" style="text-decoration:none"><?php echo $b."";?> </a>



<?php

}

}
else
{
echo "NO Record";

}
mysql_close($con);
    ?>

This 这个

echo "data fetched sucessfully";
?> 
</tbody>
</table>

means the message is inside your table. 表示邮件在您的表格内。 It just needs to come after the closing table tag instead. 它只需要在结束表标记之后。

?> 
</tbody>
</table>
<?php echo "data fetched sucessfully"; ?>

I think the align="left" in your <table> tag is what is causing the message to display beside it. 我认为<table>标记中的align="left"是导致消息显示在其旁边的原因。 It would be a good idea to remove it anyway, because this attribute has been deprecated and should not be used. 无论如何都将其删除是个好主意,因为此属性已被弃用 ,不应使用。 If you need to control the position of the table, you can use CSS instead. 如果需要控制表的位置,则可以使用CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM