Click to See Complete Forum and Search --> : Weird


The Little Guy
08-05-2006, 09:31 PM
I am having a problem with this code. It doesn't work correctly. It displays all the information from the database (case "edit"), but when I click on a link it makes, it reloads the page, but the table is smaller, and then I click on a link again, and it goes to case "view"
case "edit":
$sql = "SELECT * FROM user ORDER BY last";
$sql_query = mysql_query($sql);
echo'<table width="25%">
<tr>
<th>Last</th>
<th>First</th>
<th>Session</th>
</tr>';
while($row = mysql_fetch_array($sql_query)){
echo'<tr>
<td>'.$row[last].'</td>
<td>'.$row[first].'</td>
<td><a class="contenttxt" href="'.$_SERVER['PHP_SELF'].'?page=view&amp;user='.$row[session_id].'">'.$row[session_id].'</a></td>
</tr>';
}
echo'</table>';
break;
case "view":
if(!isset($_POST['submit'])){
$sql = "SELECT * FROM user WHERE session_id='$_GET[user]'";
$sql_query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($sql_query);
echo'<form action="'.$_SERVER['PHP_SELF'].'?page=view&amp;user='.$_GET[user].'" method="post">
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="first" value="'.$row['first'].'"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="last" value="'.$row['last'].'"></td>
</tr>
<tr>
<td>Session Number:</td>
<td><input type="text" name="number" value="'.$row['session_id'].'"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="password" value="'.$row['password'].'"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Change"></td>
</tr>
</table>
</form>';
}else{
if($_SESSION['id'] != 1){
echo'<h2>You don\'t have access</h2>';
}else{
mysql_query("UPDATE user SET first='$_POST[first]', last='$_POST[last]', session_id='$_POST[number]', password='$_POST[password]' WHERE session_id='$_POST[number]'")or die(mysql_error());
echo'Information Successfully Changed.';
}
}
break;

The Little Guy
08-05-2006, 10:12 PM
I found out, that if I remove width=25% from the code, it works fine, but I would like it in the code, I tried to make it css too, but that did the same thing. I don't know, anyone help?