在php中回发获取表格单元格值

时间:2015-08-24 19:17:38

标签: php

我有两列的表,每行包含列值和显示按钮。当我单击该行上的“显示”按钮时,该行的值将可见。一旦我得到该值,我必须将该值传递给存储过程并获得其他值。请帮助我。下面是我的PHP代码:

 <?php  
//$a = $_POST['findSchool'];
if(isset($_POST['findSchool'])){
 $_SESSION['a'] = $_POST['findSchool'];
}
$a = $_SESSION['a'];

 //1. Enter DB credentials
$servername = "****";
$username = "****";
$password = "****";
$dbname = "****";
$flag = 0;

// 2.Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
echo '<form id="myNewForm" name="myNewForm" class="form"  method="post" action="">';
echo '<table class="table table-bordered">';
echo '<tr scope="col" >
                   <th align="center">SchoolName</th> 
                      <th align="center">Details</th>                
                  </tr>';
$sql = "SELECT schName FROM schoolinformation WHERE schName LIKE '%$a%'";
$i = 0;
$result = mysqli_query($conn, $sql);
while($rowval = mysqli_fetch_array($result))
{
$schName= $rowval['schName'];
echo '<tr scope="col"><td  align="center">'.$schName.'</td>
                   <td align="center"><input type="submit" id="shwData" name="shwData" class="btn" value="Show"/></td>';
}
echo '</table>';
echo '</form>';

if($schName == '')
{echo "Entry not found";
$flag = 1;}
else{
//echo $schName;
$flag = 0;}
?>  


<?php
if(isset($_POST['shwData']))
{
echo $schName;
echo "this is it";
}
?>

0 个答案:

没有答案