Jump to content

omesa

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

omesa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I had posted earlier on a system am working on I got stuck earlier on but I managed to correct the error, now am stuck again. I want to insert into my database the value "Active" if the points are less than 10, otherwise update the database with "Pending" value if the points are greater than 10, as in; MPoints MStatus 9 Active 10 Active 11 Pending 12 Pending Here's the code am currently using, it inserts into two rows, where the results are something like MPoints MStatus 9 0 Active 10 0 Active 11 0 Active [code] $upoints = mysql_query("update members set MPoints = MPoints+1");         $result2 = mysql_query("SELECT mpoints,mstatus FROM members WHERE id = '$id'");         if (mysql_num_rows($result2) <= 10)           { # not found           $result = mysql_query("INSERT INTO members (mstatus) VALUES ('Active')");                     }         else         {           $result = mysql_query("UPDATE members SET mstatus = 'Pending' WHERE id = '$id'");                   } [/code] How do I achieve this: MPoints MStatus 9 Active 10 Active 11 Pending 12 Pending any help would be greatly appreciated. regards clement
  2. Hello guys Its afternoon this side of Africa. I have a school project where a user register and they earns points. When the points are 10, the first user is either deleted from the database and/or retained in the system, either way the second person gets their points... and the list goes on. here's what i've done. <html> <head> <title>insert</title> </head> <body> <?php include "config.php"; global $Names,$Counter; $selected_id = addslashes('$id'); $new_name = addslashes('$Names'); $new_counter = addslashes('$Counter'); //inserting into the memberchild and the members tables repectively. $mcquery = "insert into memberchild(Counter) values ('$Counter')"; $user_id = mysql_insert_id($conn); $mquery = "insert into members(id,Names) values('$user_id', '$Names')"; $m_query = mysql_query($mquery); $mc_query = mysql_query($mcquery); //update points at the members table $upoints = mysql_query("UPDATE members SET MPoints = MPoints+1 where id =".$m_query); //record number $query = "select names, mpoints from members"; $result = mysql_query($query); $recordcount = mysql_num_rows($result); echo "There are $recordcount record(s)"; ?> </body> </html> the problem lies in the members table where only the first row is incremented, I would like to see something like , name: points omesa: 2 clement: 1 ongera: 0 on the same table, after the record(s) have been inserted. I use the Names field only for inserting the record(s). For further clarification, I can provide more information. Thanks alot Any help will be appreciated.
  3. Hello guys, I have a problem with the code below. The script is meant to insert the values collected from a form and be inserted into two tables namely the client table(main) and a clientchild table(child) repectively. The members's values are inserted well but the problem is that the clientchild's values aren't added, but when I interchange the codes, they are added to the child table and vis a vis. any help will be appreciated. thank you in advance. here's the code <html> <head> <title>insert</title> </head> <body> <?php global $Names,$Kounta; $new_name = addslashes('$Names'); $new_kounta = addslashes('$Kounta'); $conn = mysql_connect("localhost", "root", "")or die("Can't connect"); mysql_select_db("myndb",$conn) or die("Can't select!"); //insert into main client table $squery = "insert into client(id,Names) values('NULL', '$Names')"; $result = mysql_query($squery, $conn); if(isset($id)) {   //get user id   $user_id = mysql_insert_id($conn);     //insert into clientchild table   $squery = "insert into clientchild values('$Kounta', $user_id)";   $result = mysql_query($squery,$conn); } ?> </body> </html>
×
×
  • 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.