/    Sign up×
Community /Pin to ProfileBookmark

I am having a problem with this code. It doesn’t work correctly. It displays all the information from the database ([B]case “edit”[/B]), 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 [B]case “view”[/B]

[code=php] 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;[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@The_Little_GuyauthorAug 06.2006 — I found out, that if I remove [B]width=25%[/B] 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?
×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...