Jump to content

Miss-Ruth

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Female

Miss-Ruth's Achievements

Member

Member (2/5)

0

Reputation

  1. Isn't there a solution as it is? I managed to the calculations and the count. The only thing I'm missing here is that how to update each row with the count value. the array simply won't do it. Ruth.
  2. Those are existing databases. How do I update each row in Achieved?
  3. Hi Ken, here is a module of my project. my_db1 example structure student | exama | examb | examc | examd .... up to examh | Achieved Ruth | A+ | C | C | A+ .... up to C | Martin | A+ | C | B | examd .... up to A | Nathan | A+ | A | C | examd .... up to C | //40 students are in the db. my_db2 example structure semester | qualifieda | qualifiedb | qualifiedc | qualifiedd .... up to qualifiedh semester1 | A+ | A | B | B .... up to A //end of db I want to update each row in Achieved with the COUNT of the matching results in exama, examb, examc etc... of my_db1 against qualifieda, qualifiedb, qualifiedc, etc... in my_db2. In this example the Achieved column should fill as Achieved 1 3 2 Hope it makes sense. Thanks, Ruth.
  4. Could anyone help me in getting the array loop fixed please? Ruth.
  5. ok... I got it fixed to a certain extent. But my loop is not functioning. Could someone help in fixing this so it loops through all the rows. //loop through all rows in my_db $query=mysql_query("SELECT * FROM my_db"); $rownum=mysql_num_rows($query); for($i=0;$i<$rownum;$i++) { $query=mysql_query("SELECT * FROM my_db LIMIT $i,1"); while($scoreU=mysql_fetch_array($query)) { foreach (range('a','h') as $ltr) { $ArrayNew[] = array($scoreU['roundzA' . $ltr]); } $count = array(); for($i=0;$i<count($ArrayNew);++$i) { $count[$i] = count(array_intersect($ArrayNew[$i],$ArrayOld[$i])); } $count1 = array_sum($count); $My_points = $count1; $update=mysql_query("UPDATE my_db SET points='$My_points'"); } }
  6. Killer1390 - Thanks for your input. kenrbnsn - Thanks. But below is my full script and I was trying to update each row with a different value. In that script I'm trying to: get data from two databases (sub_db and master_db) and match the data between the two databases then get the count of the matching data. (I managed to succeed up to this stage) now i want to match data on each row of a database against only the first row of the other database. (E.g. all rows of sub_db against master_db's first row) then update the column "the_points" for each row. <?php $conn = mysql_connect("localhost","un","pw"); mysql_select_db("the_db"); $ArrayUs1 = array(); $ArrayMk1 = array(); //master_db $query1 = "SELECT * FROM master_db WHERE round_one = round_one"; $result = mysql_query($query1); $scoreM = mysql_fetch_assoc($result); foreach (range('a','h') as $ltr) { $ArrayMk1[] = array($scoreM['my_win' . $ltr]); } //sub_db $query=mysql_query("SELECT * FROM sub_db"); $rownum=mysql_num_rows($query); for($i=0;$i<$rownum;$i++) { $query=mysql_query("SELECT * FROM sub_db LIMIT $i,1"); while($select=mysql_fetch_array($query)) { $scoreU = mysql_fetch_assoc($select); foreach (range('a','h') as $ltr) { $ArrayUs1[] = array($scoreU['first_round' . $ltr]); } $count = array(); for($i=0;$i<count($ArrayUs1);++$i) { $count[$i] = count(array_intersect($ArrayUs1[$i],$ArrayMk1[$i])); } $count1 = array_sum($count); $my_poins = $count1; $update=mysql_query("UPDATE sub_db SET the_points='$my_poins'"); } } ?> I really appreciate your help. Thanks, Ruth \-)
  7. I'm trying to update each row in my table with $upoin. But doesn't. No errors shown but it dosen't update the database (table) with $upoin. $count1 = array_sum($count); $upoin = $count1; $query=mysql_query("SELECT * FROM table"); $rownum=mysql_num_rows($query); for($i=0;$i<$rownum;$i++) { $query=mysql_query("SELECT * FROM table LIMIT $i,1"); while($select=mysql_fetch_array($query)) { $update=mysql_query("UPDATE table SET cat_num=$upoin"); } } Help fix the code. Thanks, Ruth \-)
  8. That did not solve the problem. I believe the syntax is correct <?php $link = mysql_connect("localhost","un","pw"); mysql_select_db("the_db"); $data1 = $_POST['data1']; $data2 = $_POST['data2']; $data3 = $_POST['data3']; $result =sprintf("SELECT * FROM my_db1 WHERE username ='%s'", mysql_real_escape_string($data1)); $resultf = mysql_query($result); if (mysql_num_rows ($resultf) > 0){ $register = "Retry."; echo($register); } else { $go =sprintf("INSERT INTO my_db1 (surname, firstname, username) VALUES ('%s', '%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2), mysql_real_escape_string($data3); $go1 =sprintf("INSERT INTO my_db2 (surname, firstname) VALUES ('%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2)); $resultg1 = mysql_query($go1); $go2 =sprintf("INSERT INTO my_db3 (surname, firstname) VALUES ('%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2)); $resultg2 = mysql_query($go2); $go3 =sprintf("INSERT INTO my_db4 (surname, firstname) VALUES ('%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2)); $resultg3 = mysql_query($go3); } ?> I appreciate any help. Thanks, Ruth.
  9. This looks perfect but for some reason it's not functioning. Could someone help fixing this. $resultF =sprintf("SELECT * FROM xy_db WHERE clubname ='%s'", mysql_real_escape_string($data3)); $resultFin = mysql_query($resultF); if (mysql_num_rows ($resultf) > 0){ $register = "Retry."; echo($register); } else { $go =sprintf("INSERT INTO ab_db (surnamez, firstnamez) VALUES ('%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2)); $result = mysql_query($go); Thank you. Ruth. \-)
  10. I thought you had answered . Ruth.
  11. Could someone hemlpme on this please. ALTER TABLE tb1 MODIFY field1 NOT NULL;
  12. How can I change Yes to No for the NULL field in the mysql db structure. E.g. (Table name: address and Column name : state) <?php $link = mysql_connect("localhost","db","pw"); mysql_select_db("db"); mysql_query("alter table address modify state null NO); $result = mysql_query($query); $sent = "Edit Successful."; echo ($sent); ?>
  13. Ok. I'm using this to create a countdown timer. Could someone show me how this should be done or how can I get the time difference between $start_time and $end_time stop at 0. <?php $timezone = new DateTimeZone('Africa/Gaborone'); $date = new DateTime('now', $timezone); $start_time=strtotime($date->format('Y-m-d H:i:s')); $end_time=strtotime("2010-12-14 17:9:0"); echo round(abs($start_time - $end_time)); ?> Thanks, Ruth.
  14. Anyone please... Thanks, Ruth.
  15. As you see this outputs the time in seconds. I don't think that's the issue here. It' that this difference never ends. When it reach 0 it jumps into another value and start it all over again. Ruth.
×
×
  • 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.