Jump to content

techker

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by techker

  1. sorry..i will try to find tutorials on this..
  2. 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...
  3. 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]
  4. ouff..getting heavy for me..lol thx for the help by the way.. so $fieldCnt = 0; returns in input name="Name[$fieldCnt]-Contact[$fieldCnt]-Periode[$fieldCnt] So how does it know witch field is what? shouldnt i do $fieldCnt = 0 $fieldCnt2 = 1....
  5. ok i get it.so after i can pull the information faster and more efficient. So my question is .i made the script that populates the page by Grade(1-2-3-4-5-6) so the teacher selects the students that are in her class and submits to insert in DB.. simple said...but not done.this is an issue for me.. so i have the form set up as: // get value of id that sent from address bar $Sec = $_GET['Sec']; // Retrieve data from database $sql="SELECT * FROM Etudiant WHERE Secondaire='$Sec'"; $result=mysql_query($sql); echo '<form name="Edit" method="post" action="update.php"> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Name:</strong></td> <td align="center"><strong>Contact:</strong></td> <td align="center"><strong>Periode:</strong></td> <td align="center"><strong>Select:</strong></td> </tr>'; while ($row = mysql_fetch_assoc($result)) { //we will echo these into the proper fields echo '<tr> <td align="center"><input name="Name" type="text" id="Name" value="'.$row['Code_P'].'"></td> <td align="center"><input name="Contact" type="text" id="Contact" value="'.$row["Nom"].'" size="15"></td> <td> <select name="Periode"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> <td> <input name="Name" type="checkbox" id="Select" value="'.$row['Code_P'].'"> </td> </tr>'; } echo '<tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form>'; // close connection mysql_close(); so its the insert part that confuses me..
  6. so the table issue would be to make a table for every class and add to students in it.. so the teacher would creat her class then add the students in her class table.. as fo the insert part.how can i insert the values?were do the values come from? this:?$id = implode("'),('",$checkbox);
  7. true.how would you make the table?
  8. but how to do it to insert multiple values in database?
  9. i got this $conn = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect to database!"); mysql_select_db($db, $conn); if(isset($_POST['checkbox'])){$checkbox = $_POST['checkbox']; if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"]) $id = "('" . implode( "','", $checkbox ) . "');" ; $sql="INSERT INTO `Classes` (`Etudiant` ) values ('$id')" ; $result = mysql_query($sql) or die(mysql_error()); } $sql="SELECT * FROM Etudiant"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8"" /> <title>Update multiple rows in mysql with checkbox</title> <script type="text/javascript"> <!-- function un_check(){ for (var i = 0; i < document.frmactive.elements.length; i++) { var e = document.frmactive.elements[i]; if ((e.name != 'allbox') && (e.type == 'checkbox')) { e.checked = document.frmactive.allbox.checked; }}} //--> </script> </head> <body> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="frmactive" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1"> <tr> <td colspan="5"><input name="activate" type="submit" id="activate" value="Select" /> </td> </tr> <tr> <td> </td> <td colspan="4"><strong>Update multiple rows in mysql with checkbox</strong> </td> </tr><tr> <td align="center"><input type="checkbox" name="allbox" title="Select or Deselct ALL" style="background-color:#ccc;"/></td> <td align="center"><strong>Id</strong></td> <td align="center"><strong>Firstname</strong></td> <td align="center"><strong>Lastname</strong></td> <td align="center"><strong>Status</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['Code_P']; ?>"></td> <td><? echo $rows['Code_P']; ?></td> <td><? echo $rows['Nom']; ?></td> <td><? echo $rows['Prenom']; ?></td> <td><? echo $rows['Foyer']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center"> </td> </tr> </table> </form> but i get this You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ABDA16059609','ABOD20609508','ABOA06599807');')' at line 2 i think it's because it is inserting all in on column. in need it to instert in but seperatly..
  10. Hey guys im confused on something..lol so what im doing is searching my databse for specific terms.. no that part is good. the part were i need guidance is i need to list the results but put a checkbox beside it to select multiple results to insert in a database example select * from students were grade = 3 results: matthew d checkbox luis m checkbox mike a checkbox .... so once they press submit it inserts the selected studenst in a class database.
  11. ya i seen your page.. but the thing is is that the first query is for the second to work.. inless i can do an inner join ? cause i can't put the second query but on the first i can't.. if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } while ($row = mysql_fetch_array()) { .... }
  12. well what mess is me up is that i have 1 query that depends on the other.. the first $Etudiant=$_GET['E_ID']; $query = "SELECT * FROM `Etudiant` WHERE `Code_P` ='$Etudiant'"; $numresults=mysql_query($query); $row10 = mysql_fetch_assoc($numresults); get the id and the second gets the search results in another table $Nom = $row10["Nom"]; $Prenom = $row10["Prenom"]; $fileSQL="SELECT `N_Etudiant` FROM `Expulsion` WHERE `Nom` LIKE '$Nom' AND `Prenom` LIKE '$Prenom' LIMIT 0 , 30"; $fileLIST=mysql_query($fileSQL);
  13. hey guys i keep on getting this error when i have no results..i need a full no results.. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/techker/public_html/Site/New/Main/Rapport.php on line 46 No results found. Please check often to see if we have more data.. $Etudiant=$_GET['E_ID']; $query = "SELECT * FROM `Etudiant` WHERE `Code_P` ='$Etudiant'"; $numresults=mysql_query($query); $row10 = mysql_fetch_assoc($numresults); if ($row10 == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: returned zero results</p>"; } $Nom = $row10["Nom"]; $Prenom = $row10["Prenom"]; $fileSQL="SELECT `N_Etudiant` FROM `Expulsion` WHERE `Nom` LIKE '$Nom' AND `Prenom` LIKE '$Prenom' LIMIT 0 , 30"; $fileLIST=mysql_query($fileSQL); if(mysql_num_rows($fileLIST) > 0){ while ($row = mysql_fetch_array($fileLIST)) {
  14. 12/05/11 9:13 am with var $date = date ('m/d/y g:i a');
  15. ok so i set the current date to $date_o = date ('m/d/y'); cause it inserts :$date = date ('m/d/y g:i a'); 12/05/11 9:13 am 70.29.200.146 techker but still nothing?is the AND ok?
  16. the current date is good i added the quote but still no update?
  17. hey guys i need to update my traffic table with the log out time.. i record logging and would like to add the log out time.. i tried this..no success date_default_timezone_set('EST'); //Time & Date $date = date ('m/d/y g:i a'); $ip = $_SERVER['REMOTE_ADDR']; $query = "UPDATE `traffic` SET `page` = '$date' WHERE `date` = CURDATE() AND 'ip' = '$ip"; $results = mysql_query( $query );
  18. techker

    If in query

    ha lol we were posting at the same time..thx
  19. techker

    If in query

    ok got it to work $query = "SELECT * FROM Message WHERE `Status` = 'No'"; $numresults=mysql_query($query); ///results if (!$numresults) { $message = 'Pas de Message: ' . mysql_error() . "\n"; die($message); } else { while ($row = mysql_fetch_assoc($numresults)) { echo "etudiant: ".$row['Etudiant']." du foyer ".$row['Foyer']." secondaire ".$row['Secondaire']." arrive .<br />"; echo "Notes ".$row['Notes'].".<br />"; echo "<embed src =\"$file\" hidden=\"true\" autostart=\"true\"></embed>"; } }
  20. techker

    If in query

    hey guys i want to echo a sound when there is a message in my Db with status No i think im close..sound plays all the time..even if the message has status Yes... $query = "SELECT * FROM Message WHERE `Status` = 'No'"; $numresults=mysql_query($query); $row10 = mysql_fetch_assoc($numresults); if ('Status' == 'Yes') { $message = 'Pas de Message: ' . mysql_error() . "\n"; die($message); } else { echo "<h1>1 message</h1>"; echo "<embed src =\"$file\" hidden=\"true\" autostart=\"true\"></embed>"; }
  21. ya..i tryed.. mysql_connect($db_host,$db_username,$db_password); @mysql_select_db($db_database) or die( "Unable to connect to database."); $fname = $_FILES['sel_file']['name']; $table = "Etudiant"; $sql = "LOAD DATA INFILE '$fname.xls' REPLACE INTO $table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES "; what if in the exported file there is no field id.. i needed to add the fields to the exported csv ,..
  22. can i make a page an in it it has hidden fields of the loggin for with a session var that would post the current user to the new page? the only thing is the password?inless if there is a way to use only sessions to detect if he is already in a session..
  23. Hey guys i have to choices either .txt or .xls or even .htm file to upload to my MYSQL DB.. we have a school software that export all the students in .txt-.htm-.xls files.. so im trying to see witch file would be the easiest to work with... so i got this going $file = "LT.txt"; $fp = fopen($file, "r"); $data = fread($fp, filesize($file)); fclose($fp); $output = str_replace("\t|\t", "|", $data); $output = explode("\n", $output); foreach($output as $var) { $tmp = explode("|", $var); $Ecole = $tmp[0]; $N_Fiche = $tmp[1]; $Nom = $tmp[2]; $Prenom = $tmp[3]; $Code_P = $tmp[4]; $sql = "INSERT INTO Etudiant SET Ecole='$Ecole', N_Fiche='$N_Fiche', Nom='$Nom',Prenom='$Prenom',Code_P='$Code_P'"; mysql_query($sql); } echo "Done!"; So it works but it only does the first row ..so i open the txt file it noticed that there is no coma or anything sepereating the data..just a space... like: 263 7924004 tim allan ABtim16059609 801 3 1 116263560
×
×
  • 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.