benji87 Posted June 12, 2006 Share Posted June 12, 2006 Hi all. Im currently trying to develop a posts approval system where an administrator has to approve the post before it is published live onto the web.This includes the option to edit, delete and publish the article etc.What i had in mind was a list of posts pending to be approved displayed when the admin logs in drawn from an sql database but i then want them to be able to click a button next to the title of the article for whatever action they wish to take.Ive thought alot about this idea and cant see a logical way of doing it with PHP. Ive done some research and it seems the only way to do this kind of thing is by using ASP.I have no knowledge of ASP what so ever so i dont know if its the right solution or not? If there is a way of doing this kind of thing using PHP then id love to know!! If not can someone confirm that ASP is the way forward for me...?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/ Share on other sites More sharing options...
.josh Posted June 12, 2006 Share Posted June 12, 2006 in your table that holds the post information, add another column called "published" or whatever. when the user first submits the posts, the published column would be inserted as false, 0 or whatever. On your page that displays the posts, select only ones that show published as true or 1 or whatever. in your admin section, display the unpublished ones based on 'published' being false or 0. when you are echoing them out, echo your normal editing options. the admin can edit it or whatever, save it and update the database. But it would still be unpublished. So in your admin section also have a published/unpublished radio button or however you wish to set it up according to your own tastes, and when you click on it or whatever, it updates the "published" column to true/1 or whatever.or in the admin just dump all of the posts out with add/edit options and maybe a radio tag to change it from published to unpublished. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-44644 Share on other sites More sharing options...
trq Posted June 12, 2006 Share Posted June 12, 2006 there would be no difference in implimenting this in php or asp, the concept would be simular no matter what the language.The simplest approuch would simply to have a field called [i]islive[/i] in your articles table, set this to 0 by default (not live), then, as an articles goes [i]live[/i] update this value to 1.To retrieve all [i]live[/i] articles a query might look like....[code]SELECT * FROM article WHERE islive = 1;[/code]Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-44645 Share on other sites More sharing options...
benji87 Posted June 13, 2006 Author Share Posted June 13, 2006 Ok that makes perfect sense. But when the admin logs in i want them to have options next to the title of the articles waiting to be published. Like so:DATE | TITLE | ___________________________________________________________________12/05/06 New times ahead | EDIT | | DELETE | | APPROVE |___________________________________________________________________23/06/06 Launch day | EDIT | | DELETE | | APPROVE |This would be how the data called from the database would be shown with next to each title the three buttons if the user decides that the article is not suitable then they would click delete. How do i make it so it knows that i want to delete that article on that line? the same with edit and approve. Also how would i display the buttons would i base the img url in the database or stick them in html? Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45041 Share on other sites More sharing options...
trq Posted June 13, 2006 Share Posted June 13, 2006 Its quite simple. Just make your links pass some details through the querystring.... something like....[code]$id = row['aricleid']; // <-- retrieved from the database with article.echo "<a href=\"actions.php?action=edit&id=$id\">edit</a>";[/code]Then... on actions.php decide what to do....[code]<?php if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': // do edit stuff. case 'update' // do update stuff. } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45085 Share on other sites More sharing options...
benji87 Posted June 15, 2006 Author Share Posted June 15, 2006 I get this error when trying to execute the display page:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected '[' in /homepages/33/d69713911/htdocs/webs/examples/post/display.php on line 35[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45891 Share on other sites More sharing options...
trq Posted June 15, 2006 Share Posted June 15, 2006 Um... It helps if you actually post your problematic code. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45905 Share on other sites More sharing options...
benji87 Posted June 15, 2006 Author Share Posted June 15, 2006 [code]<?require_once('db.php');$query=("SELECT * FROM postapproval ORDER BY id DESC");$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();$i=0;while ($i < $num) {$id=mysql_result($result,$i,"id");$poster=mysql_result($result,$i,"poster");$message=mysql_result($result,$i,"message");$title=mysql_result($result,$i,"title");$date=mysql_result($result,$i,"date");$time=mysql_result($result,$i,"time");$dellink=mysql_result($result,$i,"dellink");?><body><table width="71%" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="18%"><? echo"$date" | "$time" ?></td> <td width="53%"><? echo "$title" ?></td> <td width="4%"><? $id = row['id']; echo "<a href='actions.php?action=edit&id=$id'><img src='editbutton.jpg'></a>" ?></td> <td width="20%"></td> <td width="23%"></td> </tr></table></body><?$i++;}?>[/code]the bit in question is $id = row['id'] Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45915 Share on other sites More sharing options...
wisewood Posted June 15, 2006 Share Posted June 15, 2006 you should have this:$id = $row['id'];Although that wont work because you havent set the $row[] array anywhere.What you should do is ditch the whole $id = row['id']; and leave it out, as you have already specified the $id variable above. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45924 Share on other sites More sharing options...
benji87 Posted June 15, 2006 Author Share Posted June 15, 2006 Ok that worked fine thanks! Now i dont understand the actions.phpI dont have a clue what code i need to use with that snipet that was provided.Obviously i want a a text box with the article text in it so the admin can just edit it then submit itto update which is easy enough but will i need a seperate php file to do that? Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45932 Share on other sites More sharing options...
trq Posted June 15, 2006 Share Posted June 15, 2006 Really... were not going to write the thing. I'll try and explain a bit more.[code]<?php if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': // here you'll need to run a query to retrieve the selected record // and display it in a textarea contained within a form. eg $sql = "SELECT message FROM postapproval WHERE id = '{$_GET['id']}'"; // this form will then either need to post to another page, or you // could create another switch() to check the $_POST array. case 'update' // do update stuff. } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-45951 Share on other sites More sharing options...
benji87 Posted June 16, 2006 Author Share Posted June 16, 2006 Ok that last post made it alot easier to understand so thanks!Ive tried it and i keep getting a unexpected $ parse error on line 28. Im guessing this is something to do with it not picking up the id variable but im probably totally wrong![code]<? if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': require_once('db.php');$query=("SELECT message FROM postapproval WHERE id = '{$_GET['id']}'");$message=mysql_query($query);mysql_close();?><body><form name="" method="post" action=""><textarea name="textarea"><? echo "$message" ?></textarea></form></body></html>[/code]Thanks Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-46251 Share on other sites More sharing options...
benji87 Posted June 20, 2006 Author Share Posted June 20, 2006 Can someone please help? Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47603 Share on other sites More sharing options...
Orio Posted June 20, 2006 Share Posted June 20, 2006 Try:[code]<?php if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': require_once('db.php');$query=("SELECT message FROM postapproval WHERE id = '$_GET['id']'");$message=mysql_query($query);mysql_close();break;};};?><body><form name="" method="post" action=""><textarea name="textarea"><?php echo($message) ?></textarea></form></body></html>[/code]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47608 Share on other sites More sharing options...
benji87 Posted June 20, 2006 Author Share Posted June 20, 2006 That worked great! Only trouble is it doesnt retrieve the message data for some reason it fills the text box with 'Resource id #3' anybody know what that came out of??Thanks Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47612 Share on other sites More sharing options...
benji87 Posted June 20, 2006 Author Share Posted June 20, 2006 Right this is my complete code although it still does not work although i dont get any syntax errors![code]<?phpsession_start();include ('db.php'); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': $query=("SELECT message FROM postapproval WHERE id = '{$_GET['id']}'");$message=mysql_query($query);mysql_close();break; case 'delete':$query=("DELETE FROM postapproval WHERE id = '{$_GET['id']}'");mysql_close();header("Location: display.php");break; case 'approve':$query=("UPDATE postapproval SET postlevel = 1 WHERE id = '{$_GET['id']}'");mysql_close();header("location: index.php");};};?><body><form action="update.php" method="post" name="editarticle" id="editarticle"><p> <textarea name="edited" id="edited"><?php echo ("$message") ?></textarea></p><p> <input name="Update" type="submit" id="Update" value="Update"></p></form></body></html>[/code]As i said when i click update to carryon over to this code it fills the text box with text saying 'Resource id #3' i dont have a clue what that is all about. Ive also tried delete and that does absolutly nothing!Please help me i really need to get this sorted! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47637 Share on other sites More sharing options...
benji87 Posted June 20, 2006 Author Share Posted June 20, 2006 Ok ive got the update working finally! Now its just the delete function that wont work! Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47656 Share on other sites More sharing options...
trq Posted June 20, 2006 Share Posted June 20, 2006 What do you meen by [i]won't work[/i]? Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47658 Share on other sites More sharing options...
benji87 Posted June 20, 2006 Author Share Posted June 20, 2006 It doesnt delete the record from the database it just refreshes the page to display.php same with the approve it doesnt update the field to 1.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47671 Share on other sites More sharing options...
benji87 Posted June 21, 2006 Author Share Posted June 21, 2006 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/11785-live-data/#findComment-47941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.