While I'm on it...
The same news thing described in the UNIXTIME subject is giving me problems on the admin's side.
The adding works great, however in order to delete, it seems to be tricky.
Each admin only has access to certain sections of the site. These are described in a SET column, for example "main,sec1,sec2,sec3", etc.
The section they're posting to is selected from a dropdown list, which (I believe) I've gotten to check from the admin's permissions column and only show those they have access to. The one they select is saved in the appropriate column in the news database once the news item is submitted. This column is currently a SET column, which I should really change over to an ENUM.
To delete, however, I need to be able SELECT from the news database all the sections the admin has permissions for. Simply put, it isn't working.
Here's the code:
<pre>
$newsquery = "SELECT date,subject FROM news WHERE";
if (ereg('main',$section)){ $newsquery .= " section=\'main\',"; }
if (ereg('sec1',$trads)){ $newsquery .= " trads=\'sec1\',"; }
if (ereg('sec2',$trads)){ $newsquery .= " trads=\'sec2\',"; }
if (ereg('sec3',$trads)){ $newsquery .= " trads=\'sec3\',"; }
[etc.]
$newsquery = substr($newsquery, 0, -1);
$newsquery .= " ORDER BY date DESC";
$newsresult = mysql_query($newsquery);
while ($row = mysql_fetch_array($newsresult)) {
echo "<option value=http://www.phpbuilder.com/board/archive/index.php/\"".$row["date"]."\">".$row["subject"]."</option>";
}
</pre>
This is missing the opening and closing "select" tags for the listbox, obviously, but you get the idea.
This comes down to syntax, I think, how to find more than one option from a single query. I'm sure this is possible, I'm just going about it wrong.
Any ideas? Or is what I'm trying to do completely impossible?
-Ian
The same news thing described in the UNIXTIME subject is giving me problems on the admin's side.
The adding works great, however in order to delete, it seems to be tricky.
Each admin only has access to certain sections of the site. These are described in a SET column, for example "main,sec1,sec2,sec3", etc.
The section they're posting to is selected from a dropdown list, which (I believe) I've gotten to check from the admin's permissions column and only show those they have access to. The one they select is saved in the appropriate column in the news database once the news item is submitted. This column is currently a SET column, which I should really change over to an ENUM.
To delete, however, I need to be able SELECT from the news database all the sections the admin has permissions for. Simply put, it isn't working.
Here's the code:
<pre>
$newsquery = "SELECT date,subject FROM news WHERE";
if (ereg('main',$section)){ $newsquery .= " section=\'main\',"; }
if (ereg('sec1',$trads)){ $newsquery .= " trads=\'sec1\',"; }
if (ereg('sec2',$trads)){ $newsquery .= " trads=\'sec2\',"; }
if (ereg('sec3',$trads)){ $newsquery .= " trads=\'sec3\',"; }
[etc.]
$newsquery = substr($newsquery, 0, -1);
$newsquery .= " ORDER BY date DESC";
$newsresult = mysql_query($newsquery);
while ($row = mysql_fetch_array($newsresult)) {
echo "<option value=http://www.phpbuilder.com/board/archive/index.php/\"".$row["date"]."\">".$row["subject"]."</option>";
}
</pre>
This is missing the opening and closing "select" tags for the listbox, obviously, but you get the idea.
This comes down to syntax, I think, how to find more than one option from a single query. I'm sure this is possible, I'm just going about it wrong.
Any ideas? Or is what I'm trying to do completely impossible?
-Ian