index.phpの更新テーブルのタブデータを更新する方法は?
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'Engineering')">Engineering</button>
<button class="tablinks" onclick="openCity(event, 'LAW')">LAW</button>
</div>
<div id="Engineering" class="tabcontent">
<table class="items">
<tr>
<th>State</th>
<th>College Name</th>
</tr>
<?php
$query = "select * from college where field = 'engineering'";
$show = mysqli_query($link,$query);
while ($fetch = mysqli_fetch_array($show))
{
?>
<tr>
<td><?php echo $fetch['state']?></td>
<td><?php echo $fetch['college_name']?></td>
<td>
<a href="edit.php?id=<?php echo $fetch['id']; ?>">edit</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
<div id="Law" class="tabcontent">
<table class="items">
<tr>
<th>State</th>
<th>College Name</th>
</tr>
<?php
$query = "select * from college where field = 'law'";
$show = mysqli_query($link,$query);
while ($fetch = mysqli_fetch_array($show))
{
?>
<tr>
<td><?php echo $fetch['state']?></td>
<td><?php echo $fetch['college_name']?></td>
<td>
<a href="edit.php?id=<?php echo $fetch['id']; ?>">edit</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
このコードで个人设定
<?php
if(isset($_POST['update']))
{
$college_name = $_POST['colleges'];
$state = $_POST['state'];
$sqli = "update college set college_name = '$college_name', state = '$state' where id = '$id'";
$results = mysqli_query($link,$sqli);
if($result == true)
{
$msg .= "<p style='color:green;'>Your data update successfully</p>";
}
else
{
$msg .= "<p style='color:red;'>Errror!</p>";
}
}
?>
<form method="POST" enctype="multipart/form-data" >
<select name="state" id="state">
<option value="<?php echo $stateid; ?>"><?php echo $statename; ?></option>
<option value="">Select State</option>
<?php
$sql = "select * from statemaster";
$result = mysqli_query($link,$sql);
while($row = mysqli_fetch_array($result))
{
echo "<option value=".$row['stateid'].">".$row['statename']."</option>";
}
?>
</select>
<select name="colleges" id="colleges">
<option value="<?php echo $college_name; ?>"><?php echo $college_name; ?></option>
<option value="">Select College</option>
</select>
<button type="submit" name='update' id='update'>update</button>
</form>
私はそれは私がURLと実行更新クエリからIDを取得个人设定ページに移動します編集ボタンをクリックしたときテーブル大学を更新した後、データは更新されますが、私が編集ページからindex.phpページに移動すると、データは同じままですが、データベースの更新データがそこにあります。では、どうすればこの問題を解決できますか?
ありがとうございました
どこ編集フォームがある: のように、変数であるindex.phpを呼び出してみては?更新クエリは機能しますか? –
はい、@Fairy Dancer – omkara
は明らかにそれについて説明していません。 http://chat.stackoverflow.com/rooms/146504/codeigniter –