Jump to content

page refresh but doubles results..


techker

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/252696-page-refresh-but-doubles-results/
Share on other sites

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.

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.

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.