lundi 23 mars 2015

php html return only one set of data records when clicking the view button

I need my system to show only the set of 'minutes' a user clicks on and not every set of minutes that the current user is involved in.


At the minute when I click the 'image' to view a set of minutes it prints out each set of minutes that user is involved in, I need it to only print out and be able to edit that one specific set of minutes... the edit function works but I just need it to print out what the user clicks on and not every set..PLEASE Can ANYONE help with this I have spent all day and don't understand how to get this to work.


Below is the code that shows the php and query in the minutes.php page, when you click the image for 'view' it takes you to the 'viewstudentminutes.php' page, I only want it to print out the minutes you click on not every set.



?php
$dbQuery = $db->prepare("select * from minute where '$currentUser'=B_number ");
$dbQuery->execute();

$numMinutes = $dbQuery->rowCount();

echo "<p>There are $numMinutes sets of minutes in the system</p>";

$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$ID = $dbRow['ID'];
$B_number = $dbRow['B_number'];
$Date = $dbRow['Date'];
$Time = $dbRow['Time'];
$Discussion = $dbRow['Discussion'];
$Actions = $dbRow['Actions'];
$Dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$Status = $dbRow['Status'];
$E_number = $dbRow['E_number'];
$Supervisor_comments = $dbRow['Supervisor_comments'];


if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;

if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$ID) {
echo "<tr class='$rowClass '>
<form style='display:inline' method='post' action='minutes.php'>
<input type='hidden' name='editCommitID' value='$ID'>
<td><input type='varchar' name='editB_number' value='$B_number'></td>
<td><input type='date' name='editDate' value='$Date'></td>
<td><input type='time' name='editTime' value='$Time'></td>
<td><input type='text' name='editDiscussion' value='$Discussion'></td>
<td><input type='text' name='editActions' value='$Actions'> </td>
<td><input type='date' name='editDateofnextmeeting' value='$Dateofnextmeeting'></td>
<td><input type='enum' name='editStatus' value='$Status'> </td>
<td><input type='varchar' name='editE_number' value='$E_number'></td>
<td><input type='text' name='editSupervisor_comments' value='$Supervisor_comments'></td>
<td colspan='2'><input type='image' src='edit.png'>
</form>
</tr>";
} else {

echo "<tr class='$rowClass'><td>$B_number</td><td>$Date</td> <td>$Time</td><td>$Discussion</td><td>$Actions</td><td>$Dateofnextmeeting</td> <td>$Status</td><td>$E_number</td><td>$Supervisor_comments</td>
<td class='operation'>
<form class='display:inline' method='post' action='minutes.php'
onsubmit='return confirm(\"Are you sure?\")'>
<input type='hidden' name='deleteMinuteID' value='$ID'>
<input type='image' src='delete.png' style='padding-top:7px'>
</form></td>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'
onsubmit='viewstudentminutes.php'>
<input type='image' src='view.png' style='padding-top:7px'>

</form></td>
</tr>";
}
}


?>


Below is the code for the 'viewstudentminutes.php' showing every set and allows you to edit each instead of just printing out the specific set clicked on at the start.



<h2>Minutes</h2>
<table class="table table-condensed">
<?php


$dbQuery = $db->prepare("select * from minute where '$currentUser'=B_number");
$dbQuery->execute();

$oddRow=true;
while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
$id = $dbRow['ID'];
$b_number = $dbRow['B_number'];
$date = $dbRow['Date'];
$time = $dbRow['Time'];
$discussion = $dbRow['Discussion'];
$actions = $dbRow['Actions'];
$dateofnextmeeting = $dbRow['Dateofnextmeeting'];
$status = $dbRow['Status'];
$e_number = $dbRow['E_number'];
$supervisor_comments = $dbRow['Supervisor_comments'];


if ($oddRow) $rowClass="odd"; else $rowClass="even";
$oddRow=!$oddRow;

if (isset($_POST['editMinuteID']) && $_POST['editMinuteID']==$id) {
echo "<tr class='$rowClass'>
<form style='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editCommitID' value='$id'>
<tr><td colspan='2'><input type='image' src='edit.png'> </tr>
<tr><th>BNumber</th><td><input type='varchar' name='editB_number' value='$b_number'></td></tr>
<tr><th>Date</th><td><input type='date' name='editDate' value='$date'></td></tr>
<tr><th>Time</th><td><input type='time' name='editTime' value='$time'></td></tr>
<tr><th>Discussion</th><td><input type='text' name='editDiscussion' value='$discussion'></td></tr>
<tr><th>Actions</th><td><input type='text' name='editActions' value='$actions'></td></tr>
<tr><th>Date of Next Meeting</th><td><input type='date' name='editDateofnextmeeting' value='$dateofnextmeeting'></td></tr>
<tr><th>Status</th><td><input type='enum' name='editStatus' value='$status'></td></tr>
<tr><th>E Number</th><td><input type='varchar' name='editE_number' value='$e_number'></td></tr>
<tr><th>Supervisor Comments</th><td><input type='text' name='editSupervisor_comments' value='$supervisor_comments'></td></tr>

</form>
</tr>";
} else {
echo "<tr class='$rowClass'>
<td class='operation'>
<form class='display:inline' method='post' action='viewstudentminutes.php'>
<input type='hidden' name='editMinuteID' value='$id'>
<input type='image' src='edit.png' style='padding-top:7px'>
</form></td>
<tr><th>BNumber</th><td>$b_number</td></tr>
<tr><th>Date</th><td>$date</td></tr>
<tr><th>Time</th><td>$time</td></tr>
<tr><th>Discussion</th><td>$discussion</td></tr>
<tr><th>Actions</th><td>$actions</td></tr>
<tr><th>Date of Next Meeting</th><td>$dateofnextmeeting</td></tr>
<tr><th>Status</th><td>$status</td></tr>
<tr><th>E Number</th><td>$e_number</td></tr>
<tr><th>Supervisor Comments</th> <td>$supervisor_comments</td></tr>
</tr>";
}
}

?>
</table>


Please help :(


Aucun commentaire:

Enregistrer un commentaire