Can't find the problem (no error message)!


Posted on 16th Feb 2014 07:03 pm by admin

OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm going to try and make it as easy as possible. Here's a breakdown of what the user should do:

1. The user sees a list of his classes (stored in the classes table in the DB). He picks one.
Code: [Select]$instructor = $_COOKIE['USERNAME'];
$query = ("SELECT * FROM classes WHERE instructor='$instructor'");

$sql = mysql_query($query) or die(mysql_error());

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<table border="1" cellspacing="2" cellpadding="3">';
while ($row = mysql_fetch_array($sql))
{

echo '<tr><td>';
echo $row['id'];
echo '</td><td>';
echo $row['session'];
echo '</td><td>';
echo $row['day'];
echo '</td><td>';
echo $row['time'];
echo '</td><td>';
echo $row['level'];
echo '</td><td>';

$class_id = $row['id'];

echo '<input type = "hidden" name = "class_id" value = "'.$class_id.'" />';
echo '<input type = "submit" name = "pickclass" value = "Run" /></form>';
echo '</td></tr>';
}

echo '</table>';
2. The user is shown a list of the students in that class. He picks one.
Code: [Select] if (isset($_POST['pickclass'])) {



echo '<table>';

$class_id = $_POST['class_id'];

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';

echo '<tr><td><strong>Instructor:&nbsp;</td></tr></table>';



echo $_COOKIE['USERNAME'];

$instructor = $_COOKIE['USERNAME'];


echo '<table border="1" cellspacing="2" cellpadding="3">';


echo '<tr><td>ID</td><td>First</td><td>Last</td><td>Gender</td><td>Level</td></tr>';

$query = ("SELECT * FROM `students` WHERE classid='$class_id' LIMIT 0, 30");

$sql = mysql_query($query) or die(mysql_error());


while ($row = mysql_fetch_array($sql)) {

echo '<tr><td>';
echo $row['id'];
echo '</td><td>';
echo $row['fname'];
echo '</td><td>';
echo $row['lname'];
echo '</td><td>';
echo $row['gender'];
echo '</td><td>';
echo $row['level'];
echo '</td><td>';

echo '<input type = "hidden" name = "id" value = "'.$row['id'].'" />';
echo '<input type = "hidden" name = "fname" value = "'.$row['fname'].'" />';
echo '<input type = "hidden" name = "lname" value = "'.$row['lname'].'" />';
echo '<input type = "hidden" name = "gender" value = "'.$row['gender'].'" />';
echo '<input type = "hidden" name = "level" value = "'.$row['level'].'" />';
echo '<input type = "submit" name = "submit" value = "GO!" /></td></tr></table></form>';


Here's the problem: the only thing showing up under step two is the table headers (i.e. First, Last, etc.)
I don't know why. I feel like it's a tiny problem but I can't find it! Help!

----

In reality, the code looks like this. Don't hurt me!
Code: [Select]//something else comes before this
else

{
if (isset($_POST['pickclass'])) {



echo '<table>';

$class_id = $_POST['class_id'];

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';

echo '<tr><td><strong>Instructor:&nbsp;</td></tr></table>';



echo $_COOKIE['USERNAME'];

$instructor = $_COOKIE['USERNAME'];


echo '<table border="1" cellspacing="2" cellpadding="3">';


echo '<tr><td>ID</td><td>First</td><td>Last</td><td>Gender</td><td>Level</td></tr>';

$query = ("SELECT * FROM `students` WHERE classid='$class_id' LIMIT 0, 30");

$sql = mysql_query($query) or die(mysql_error());


while ($row = mysql_fetch_array($sql)) {

echo '<tr><td>';
echo $row['id'];
echo '</td><td>';
echo $row['fname'];
echo '</td><td>';
echo $row['lname'];
echo '</td><td>';
echo $row['gender'];
echo '</td><td>';
echo $row['level'];
echo '</td><td>';

echo '<input type = "hidden" name = "id" value = "'.$row['id'].'" />';
echo '<input type = "hidden" name = "fname" value = "'.$row['fname'].'" />';
echo '<input type = "hidden" name = "lname" value = "'.$row['lname'].'" />';
echo '<input type = "hidden" name = "gender" value = "'.$row['gender'].'" />';
echo '<input type = "hidden" name = "level" value = "'.$row['level'].'" />';
echo '<input type = "submit" name = "submit" value = "GO!" /></td></tr></table></form>';

No comments posted yet

Your Answer:

Login to answer
193 Like 44 Dislike
Previous forums Next forums
Other forums

This must be easy , pulling the last record of the day, every day, from a txt
I have a txt file logging weather data every minutes (so 1 record per minute). I want to extract the

How to change www in url with a specified name
Hi
I'm trying to change the url http://www.sitename.com/apparels to something like below
http:

Web Host List
Here is a list of web hosts that offer PHP and MySQL. It is no where near a full list, but it is mos

TimeStamp Column Problem...
I'm mad at my self and thinking I'm a little retarded. It just be some one mistake I'm missing here.

Calculating n! using vector
#include
#include
#include

using

Finding digits in variable containing text, and IDing them
$romanstock = "http://www.remoteprice.com/data.asp?storeid=123&itemcode=456&typ

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

HTML Viewer HIDE scrollbar
How can I disable scrollbars in a HTML Viewer control? I can't hide them. Even i have enough space b

Redirect not working after making a POST/GET
Hi Everyone,

I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash