I have a page that will display the names of people from one data base that is joined with another that tracks when two names are linked. Every thing works fine. However; I cannot make the data or specifically the right user name ($id2u) and a string ($permissions) transfer from the input boxes when the user selects one. The onclick event should then show the data fields as per the permission string. The problem is the displayed info is always the last user in the DB that was ran through the loop. Am trying to get the info to carry forward on the onclick event when a check box is clicked so that their info is displayed.
This is he function to call the display of data.
function display1(type) {document.getElementById("pi").style.display = "none"
document.getElementById(type).style.display = ""}
This is the call to the DB that generated the input boxes for each person.
$result1 = mysql_query('SELECT * FROM level1 LEFT JOIN linkreq ON level1.idnumber = linkreq.idme ORDER BY LEAST(lname, fname) DESC');
for ($i = mysql_num_rows($result1) - 1; $i >= 0; $i--){
if (!mysql_data_seek($result1, $i)){echo "Cannot seek to row $i: " . mysql_error() . "\n";continue;}
if (!($row = mysql_fetch_assoc($result1))) {continue;}
if($_SESSION["idnumber"] == $row['id2u']){
if($row['returnack'] == 0){$id2u = $row['idme']; echo'<font color="#FF6600">*</font> '.$row['title'].' '.$row['fname'].' '.$row['mname'].' '.$row['lname'].' '.$row['suffex'].'<br />';}
else{
$permissions = $row['permissions'];
parse_str($permissions);
$permissions;
$id2u = $row['idme'].' ';
echo '<input type="checkbox" value = " .$id2u. " onClick="display1(\'pi\');"> '
.$row['title'].' '.$row['fname'].' '.$row['mname'].' '.$row['lname'].' '.$row['suffex'].'
<br />';}}}
This is the data that gets displayed onclick(pi)
but displays last user not the selected one. Basically if the $id2u variable data would carry over from the check box this would work. As can manually force it by setting $id2u = xxxxxx;
just before the query.
$result2 = mysql_query('SELECT * FROM pi WHERE idnumber = "'.$id2u.'"');
for ($i = mysql_num_rows($result2) - 1; $i >= 0; $i--){
if (!mysql_data_seek($result2, $i)){echo "Cannot seek to row $i: " . mysql_error() . "\n";continue;}
if (!($row = mysql_fetch_assoc($result2))) {continue;}
echo '<br>row #'.$row['idnumber'];
if($id2u == $row['idnumber']){echo'...// PRINTS OUT DATA //...}}
</span>
I know this should be in mySQLi but for now just need to get it to work will convert later.