Imbecilic, Clouseau-like noob here. I cannot seem to make this one change that I know should be easy by now.
Table like so:
id | next | group
1 | 0 | alpha
2 | 0 | alpha
3 | 0 | alpha
4 | 1 | alpha
5 | 0 | beta
6 | 0 | beta
When user 4 submits form, it updates the "next" field in user 4's row to 0, and the "next" field in user 5's row to 1, like so:
id | next | group
1 | 0 | alpha
2 | 0 | alpha
3 | 0 | alpha
4 | 0 | alpha
5 | 1 | beta
6 | 0 | beta
I would like it to restrict updates by "group" field, so that user 4's form submit results in:
id | next | group
1 | 1 | alpha
2 | 0 | alpha
3 | 0 | alpha
4 | 0 | alpha
5 | 0 | beta
6 | 0 | beta
Here is the script:
if($_POST['doWork'] == 'Done') {
mysql_query("update users set next='1' where id > '$id' LIMIT 1");
mysql_query("update users set next='0' where id='$id'");
list($highest) = mysql_fetch_row(mysql_query("select id from users where id >'$id'"));
if(empty($highest)) {
mysql_query("update users set next='1' where id > 0 LIMIT 1");
mysql_query("update users set next='0' where id='$id'");
It goes to the lowest id row when the highest id row has been reached, which is almost what I want: I would like it to stop at the highest id IN GROUP ALPHA (or whichever group the logged-in user belongs to) and go back to the lowest id in the same group.
I'm thinking:
mysql_query("update users set next='1' where group='$group' AND id > '$id' LIMIT 1");
But how/where to tell it what "$group" means?
There's a hidden GET too:
<form name="form1" method="get" action="admin.php" id="form1">
<input type="hidden" name="qoption" value="guys">
<input name="doSearch" type="hidden" id="doSearch2" value="List">
</form> </td>
</tr></table>
<?php
if ($get['doSearch'] == 'List') {
if($get['qoption'] == 'guys') {
$cond = "where `id`='$_SESSION[user_id]'";
}
if($get['qoption'] == 'guys') {
$sql = "select * from users $cond";
}
else {
$sql = "select * from users where `id` = '$_SESSION[user_id]'";
}
Should I specify the "group" requirement there instead? But how?
One of the main reasons I am doing this project is to learn, and so far it has helped a lot. Many thanks for any suggestions.