PHP'de yeni. Veriye veri ekledikten sonra neden Dept_ID
'un neden gösterilmediğini herkes anlatabilir.MySQL içine sokulduktan sonra Tanımsız ID
Veri görüntüleme sayfası: Ben formu gönderdikten sonra, ben bir hata alırsınız
<a href = "View_Section.php">Back Section</a>
<form action = "New_Section_Process.php" method = "POST">
<table align = "center">
<?php
$Dept_ID = '';
//connection to database
include("connection.php");
$Dept_ID = $_POST['Dept_ID'];
$Section_ID = $_POST['Section_ID'];
$Section_Desc = $_POST['Section_Desc'];
echo "$Dept_ID, $Section_ID, $Section_Desc";
//creating SQL statements
$query = "INSERT INTO section (Dept_ID, Section_ID, Section_Desc)
VALUES('$Dept_ID', '$Section_ID', '$Section_Desc')";
{
{ //run the SQL statement
//mysql_query is the function that is used to run query
if(mysql_query($query))
{
header('location:View_Section.php');
}
else
{
//error if query is not valid
echo "Data Already Exist!";
}
}
}
?>
: Yeni bir kayıt eklemek için
<form action = "New_Section_Process.php" method = "POST">
<table border = "1" cellpadding='10' cellspacing='0' align = "center">
<tr>
<th colspan = '3'>
<font color = "black">Section</font></th>
</tr>
<?php
include("connection.php");
?>
<tr>
<td>Department ID : </td>
<td> <select Dept_ID="dept">
<?php
$query = "SELECT * FROM dept ORDER BY Dept_ID";
$result = mysql_query($query);
if(mysql_num_rows($result)) {
while ($id = mysql_fetch_row($result))
{
echo "<option value='" . $id[1] . "'>" . $id[0] . " " .
$id[1] . " </option>";
}
} else {
echo "<option value=''>No Department </option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Section ID :</td>
<td><input type = "varchar" name = "Section_ID"
maxlength = "55" placeholder = "Enter Here">
</td>
</tr>
<tr>
<td>Section Description :</td>
<td><input type = "varchar" name = "Section_Desc"
maxlength = "55" placeholder = "Enter Here">
</td>
</tr>
<td colspan = "3" align = "center">
<input type = "submit" name = "submit"
value = "Submit">
</td>
</tr>
</table>
</form>
Kod:
<html>
<head>
<title>View Records</title>
</head>
<body>
<div id="container">
<center> <h2> SECTION RECORD </h2> </center>
<?php
// connect to the database
include('connection.php');
// get results from database
$result = mysql_query("SELECT * FROM section")
or die(mysql_error());
// display data in table
echo "<table border='1' cellpadding='20' cellspacing='0'
align = center>";
echo "<tr> <th>Department ID</th><th>Section ID</th>
<th>Section Description</th> <th> </th><th> </th>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array($result)) {
// echo out the contents of each row into a table
echo "<tr>
<td align = center>".$row['Dept_ID']."</th>
<td align = center>".$row['Section_ID']."</th>
<td align = center>".$row['Section_Desc']."</th>
<td><a href='Update_Dept.php?Dept_ID=$row[Dept_ID]
&Section_ID=$row[Section_ID]
&Section_Desc=$row[Section_Desc]'>Update</a></td>
<td><a href='Delete_Section.php?Dept_ID=$row[Dept_ID]
'>Delete</a></td>
</tr>";
}
echo "<a href = 'New_Section.php'>Add new record </a>"
?>
</div>
</div>
</body>
</html>
yeni rekor sayfası ekleyin undefined Dept_ID
.
Bunu nasıl düzeltebilirim?
, teşekkür !!: Bir if $ _GET/$ _ POST/$ _ İSTEK veri almak –