anarchoi Posted March 28, 2008 Share Posted March 28, 2008 i'm trying to make an admin section to validate modification request of articles basically, articles are stored in "news2" and modifications awaiting for moderation are stored in "bands2" I made a form in the admin section that shows modifications requests, and if submit button is hit then the modification is validated, so it is added back into "news2" here is the code if($_POST['submit']) //If submit is hit { //then connect as user //change user and password to your mySQL name and password mysql_connect("localhost","anarchoi1","************"); //select which database you want to edit mysql_select_db("anarchoi1_phpb1"); //convert all the posts to variables: $id = $_POST['id']; $theid = $_POST['id']; $title = $_POST['title']; $infos = $_POST['infos']; $web = $_POST['web']; $localisation = $_POST['localisation']; $date = $_POST['date']; $time = $_POST['time']; $actif = $_POST['actif']; $strSQL = "SELECT * FROM bands2 WHERE title='".$title."'"; $rs=mysql_query($strSQL); //execute the query $result=MYSQL_QUERY("INSERT INTO news2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); $result=MYSQL_QUERY("DELETE FROM bands2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); //confirm echo "Query Finished"; //Insert the values into the correct database with the right fields //mysql table = news2 //table columns = id, title, infos, web, localisation, date, time //post variables = $title, $infos, '$web', '$localisation, $date, $time } What i did so far is working... but the problem is that after a modification-request is validated, there is still the request in "bands2", and the article will be most-likely in double in "news2" so here's what i'd like to do: After form is sent : - Check for duplicate entry in "news2" by checking if there is already an entry with same $title - Delete the modification-request in "bands2" (the title to delete is already stored in $_GET['groupe']) As you can see i attempted to do it but i can't find a way to do an INSERT and DELETE at same time Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/ Share on other sites More sharing options...
zenag Posted March 28, 2008 Share Posted March 28, 2008 $rs=mysql_query($strSQL); if(mysql_num_rows($rs)>0) { echo "title already exists"; } else{ $result=MYSQL_QUERY("INSERT INTO news2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); } Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/#findComment-502913 Share on other sites More sharing options...
zenag Posted March 28, 2008 Share Posted March 28, 2008 else{ $result=MYSQL_QUERY("INSERT INTO news2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); $id=mysql_query("DELETE FROM bands2 WHERE id='$_POST['id']'"); } try this... Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/#findComment-502919 Share on other sites More sharing options...
anarchoi Posted March 28, 2008 Author Share Posted March 28, 2008 hmm nah it didn't work for me Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/#findComment-502939 Share on other sites More sharing options...
zenag Posted March 28, 2008 Share Posted March 28, 2008 $result=MYSQL_QUERY("select * from news2 where title='".$title."'"; if(mysql_num_rows($result)>0) { echo "title already exists"; } else{ $result=MYSQL_QUERY("INSERT INTO news2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); } this might work... Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/#findComment-502944 Share on other sites More sharing options...
zenag Posted March 28, 2008 Share Posted March 28, 2008 $result=MYSQL_QUERY("select * from news2 where title='".$title."'"; if(mysql_num_rows($result)>0) { echo "title already exists"; } else{ $result=MYSQL_QUERY("INSERT INTO news2 (id,title,infos,web,localisation,date,time,actif)". "VALUES ('$theid', '$title', '$infos', '$web', '$localisation', '$date', '$time', '$actif')"); $res=mysql_query("delete from bands2 where title='$title'"); } try this friend.... Link to comment https://forums.phpfreaks.com/topic/98279-delete-a-row-after-form-is-sent/#findComment-502950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.