techker Posted December 7, 2011 Share Posted December 7, 2011 hey guys another litle issue i just encountered..lol i refresh the page to find new content in my DB.. so it refreshes but every refresh it inserts the same value..is it possible for it to not insert the same info every refresh? include"auth_check_header.php"; require_once 'class/config.php'; $username_from_cookie = $_COOKIE[$cookiename]; //retrieve contents of cookie // connect to the database $conn = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect to database!"); mysql_select_db($db, $conn); $query = "SELECT Code_P, Prof, Status FROM Sortie GROUP BY Code_P, Prof, Status HAVING COUNT( * ) >=2 AND Status='No' LIMIT 0 , 30"; //$result = mysql_query ($query) or die ('Your query did not match any results: ' . mysql_error()); $result=mysql_query($query); while ($row = mysql_fetch_array($result)) { $N_Etudiant = $row["Code_P"]; $Professeur = $row["Prof"]; $date = date("Y-m-d"); $Status = 'No'; mysql_query("INSERT INTO `Suivit` (`Prof` ,`Etudiant` ,`Date` ,`Status` ) values ('$Professeur','$N_Etudiant','$date','$Status')"); } ?> <META HTTP-EQUIV=Refresh CONTENT="30"> [code=php:0] Quote Link to comment Share on other sites More sharing options...
requinix Posted December 7, 2011 Share Posted December 7, 2011 Yes: don't make it do the SELECT+INSERT by default. Only do that on very specific requests. Example: if a button was pushed on a form. Quote Link to comment Share on other sites More sharing options...
techker Posted December 7, 2011 Author Share Posted December 7, 2011 ok... i don't get it.. even if the button is presst i still need to look in the DB and insert the results?inless once it is insert and update query to set the status to yes... Quote Link to comment Share on other sites More sharing options...
requinix Posted December 7, 2011 Share Posted December 7, 2011 For starters remove the INSERT and its loop. You don't want that to happen every time, right? After you've made sure that it's working the way you want, start adding to the code so that when something specific happens (like a form button is pressed) only then does the INSERTing stuff happen. Quote Link to comment Share on other sites More sharing options...
techker Posted December 7, 2011 Author Share Posted December 7, 2011 well i don't want it to be manually done..i want to automatically done.. like every 30min.. i think the simple way will be to add an update query to update the status to yes. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 7, 2011 Share Posted December 7, 2011 What is this script supposed to do? Quote Link to comment Share on other sites More sharing options...
techker Posted December 7, 2011 Author Share Posted December 7, 2011 So every day there is students that get kicked out of class (remember)lol so they have this class room they go to .the teacher there inserts his name,teacher and notes in the db. when the students gets kicked out more then 2 times by the same teacher in the same week he gets a detention and the teacher must meet the parents... So i have 2 DB DB-1 is the (Sortie) detention room info.(name-teacher-notes..) DB-2 (Suivit) Fallowup So what the script does is check the DB 1 for 2 times plus with the same teacher. so it inserts in the Db2 the teacher-Student-Date... So the goal is to work with DB2 for different possibility's..(48h Followup terms) So it works now.. what im doing first is checking the recurrence's then inserting the info in the Fallowup Db the issue was it was inserting the same info all the time the page refreshed.. So i added an update status of DB1 to Yes.so it can skip that entry. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 8, 2011 Share Posted December 8, 2011 TLDR. Is the query broken or not? Quote Link to comment Share on other sites More sharing options...
techker Posted December 8, 2011 Author Share Posted December 8, 2011 no..it works now with the update status once it is inserted. Quote Link to comment 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.