Forum Moderators: coopster
php:
--------------------------------------------------------------------------------
function displayAlumni($result) {
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $data)
print "{$data}";
print "\n<input type=\"radio\" name=\"alumni\" value=\"{$row[userId]}\">";
}
$query = "SELECT userId, firstName, lastName, maidenName FROM users ORDER BY lastName ASC";
function showerror() {
die ("Error " . mysql_errno() . " : " . mysql_error());
}
if (!($result = mysql_query ($query, $connection)))
showerror(); // The DB info is in an include().
displayAlumni($result);
?>
--------------------------------------------------------------------------------
They select the user with the radio button and it posts to the next page where I want a query to display the User Information. I tried this:
php:
--------------------------------------------------------------------------------
$userId = $_POST['$row[userId]}']; // I also tried $_POST['userId'] with same result... nothing =(.
function displayAlumInfo($result) {
while ($row = mysql_fetch_array($result)) {
foreach ($row as $data)
print "{$data}";
print "\n";
}
}
$query = "SELECT * FROM users WHERE userId = '$userId'";
function showerror() {
die ("Error " . mysql_errno() . " : " . mysql_error());
}
if (!($result = mysql_query ($query, $connection)))
showerror();
displayAlumInfo($result);
?>
--------------------------------------------------------------------------------
Basically, I get nothing. Any Ideas? Thanx.
p.s. I know this shows a lack of security, but I plan on adding some htmlentities() and str_ireplace() later.
eelix
to, respectively:
print "\n<input type=\"radio\" name=\"alumni\" value=\"$row[userId]\">";
$userid = $_POST['alumni'];
The latter is because you set the name of the checkbox to 'alumni' and not 'userId'
eelix
Thanks for the help. What you suggested helped... kind of.
I played around with it and got it to display something, but it's really weird.
Here's what I've got now.
the form:
<?php
function displayAlumni($result) {
print "\n<table>\n<tr>\n" .
"\n\t<th>Alumni UserId</th>" .
"\n\t<th>Alumni First Name</th>" .
"\n\t<th>Alumni Last Name</th>" .
"\n\t<th>Alumni Maiden Name</th>" .
"\n\t<th>Select One</th>" .
"\n</tr>";
while ($row = mysql_fetch_assoc($result)) {
print "\n<tr>";
foreach ($row as $data)
print "\n\t<td><center> {$data} </center></td>";
print "\n\t<td><input type=\"radio\" name=\"alumni\" value=\"{$row[userId]}\"></td>";
print "\n</tr>";
}
print "\n</table>\n";
}
$query = "SELECT userId, firstName, lastName, maidenName FROM users ORDER BY lastName ASC";
function showerror() {
die ("Error " . mysql_errno() . " : " . mysql_error());
}
if (!($result = mysql_query ($query, $connection)))
showerror();
displayAlumni($result);
?>
the display page:
<?php
$alumni = $_POST['alumni'];
function displayAlumInfo($result) {
while ($row = mysql_fetch_array($result)) {
foreach ($row as $data)
print "{$data}";
print "\n";
}
}
$query = "SELECT * FROM users WHERE userId = '$alumni'";
function showerror() {
die ("Error " . mysql_errno() . " : " . mysql_error());
}
if (!($result = mysql_query ($query, $connection)))
showerror();
$result = mysql_query ($query);
displayAlumInfo($result);
?>
The weird thing is that it displays the Alumni Information twice. Like it returnd the data from each column and prints it twice and then goes to the next column.
What the heck did I do now?