Right now I am working on a queue moderation system and I've thought of using foreach but I'm not really sure what I am doing.
Right now I have something like this:
$query = "SELECT * FROM queue WHERE id=$loopid";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
if ($row['approved'] == '0')
{
echo $row['item'], $row['submitted_by'], "<input type=checkbox name=id[] value=1>";
}
$loopid = $loopid + 1; //++$loopid;
$query = "SELECT * FROM queue WHERE id=$loopid";
$result = mysql_query($query);
}
And it gets sent to php self
if ($_POST['submit'])
{
$approved = $_POST['approved'];
$id = $_POST['loopid'];
$sql="UPDATE queue SET approved='$approved' WHERE id=$id";
$result = mysql_query($sql);
echo "Changes were made";
}
I realize this code is probably crappy but at this point I'm not worried about the RIGHT way to do it, as long as I get the initial version up and running and can go from there, but any help would be awesome.
The red parts are where I'm thinking I would need to actually use foreach stuff but I'm not really sure.
Right now I have something like this:
$query = "SELECT * FROM queue WHERE id=$loopid";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
if ($row['approved'] == '0')
{
echo $row['item'], $row['submitted_by'], "<input type=checkbox name=id[] value=1>";
}
$loopid = $loopid + 1; //++$loopid;
$query = "SELECT * FROM queue WHERE id=$loopid";
$result = mysql_query($query);
}
And it gets sent to php self
if ($_POST['submit'])
{
$approved = $_POST['approved'];
$id = $_POST['loopid'];
$sql="UPDATE queue SET approved='$approved' WHERE id=$id";
$result = mysql_query($sql);
echo "Changes were made";
}
I realize this code is probably crappy but at this point I'm not worried about the RIGHT way to do it, as long as I get the initial version up and running and can go from there, but any help would be awesome.
The red parts are where I'm thinking I would need to actually use foreach stuff but I'm not really sure.
