誰かが入力する単純なフォームと、クエリを実行してデータを取得する別のフォームがあります。
フォームに画像のアップロードを含め、この画像を含むフォームデータを表示するテーブルを取得するというアイデアをいじっています。
これは私が持っているコードの一部です
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$uname = $_POST['username'];
$password = $_POST['password'];
$uname = htmlspecialchars($uname);
$password = htmlspecialchars($password);
//==========================================
// CONNECT TO THE LOCAL DATABASE
//==========================================
$user_name = "xxxxxx";
$pass_word = "xxxxxx";
$database = "xxxxx";
$server = "xxxxxx";
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$SQL = "SELECT * FROM students WHERE L1 = '$uname' AND L2 = '" .md5 ($_POST['password'])."'";
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
//====================================================
// CHECK TO SEE IF THE $result VARIABLE IS TRUE
//====================================================
if ($result) {
if ($num_rows > 0) {
$color="1";
$result = mysql_query("SELECT * FROM entry, students WHERE entry.studentName = students.studentName AND students.L1='$uname' ")
or die(mysql_error());
echo "<p>You records as of ";
echo date('l jS \of F Y h:i:s A');
echo "<table border='1' cellpadding='2' cellspacing='0'>";
echo "<tr> <th>Date</th><th>Student Name</th> <th>Tutor name</th> <th>Procedure name</th> <th>Grade</th><th>Student Reflection</th><th>Tutor Comments</th><th>Professionalism</th> <th>Communication</th> <th>Alert</th> <th>Dispute</th><th>Username</th> <th>Image</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
if($color==1){
echo "<tr bgcolor= >
<td>".$row['date']."</td><td>".$row['studentName']."</td><td>".$row['tutorName']."</td><td>".$row['procedureName']."</td><td>".$row['grade']."</td><td>".$row['studentReflection']."</td><td>".$row['tutorComments']."</td><td>".$row['professionalism']."</td><td>".$row['communication']."</td><td>".$row['alert']."</td><td>".$row['dispute']."<td>".$row['L1']."</td></td>
<td><img src='images/".$row['studentImage']."'></td>;
</tr>";
// Set $color==2, for switching to other color
$color="2";
}
// When $color not equal 1, use this table row color
else {
echo "<tr bgcolor='#4eb557'>
<td>".$row['date']."</td><td>".$row['studentName']."</td><td>".$row['tutorName']."</td><td>".$row['procedureName']."</td><td>".$row['grade']."</td><td>".$row['studentReflection']."</td><td>".$row['tutorComments']."</td><td>".$row['professionalism']."</td><td>".$row['communication']."</td><td>".$row['alert']."</td><td>".$row['dispute']."<td>".$row['L1']."</td></td>
<td><img src='images/".$row['studentImage']."'></td>;
</tr>";
// Set $color back to 1
$color="1";
}
}
echo '</table>';
結果が戻ってきたら、文字の負荷として表示されている画像以外のすべてのデータを取得しました。
どこが間違っていますか?