comments should be working again. not tested though
authorarun <arun@nubati.net>
Mon, 11 Dec 2006 14:09:03 +0000 (14:09 +0000)
committerarun <arun>
Mon, 11 Dec 2006 14:09:03 +0000 (14:09 +0000)
db.php
index.php

diff --git a/db.php b/db.php
index 9f002053b45b30e3b209eb6700f71b0863834b12..7f47c66e3068936fe0ad3b04c94f34994478cd0e 100644 (file)
--- a/db.php
+++ b/db.php
@@ -301,7 +301,9 @@ function DB_play_card($trickid,$handcardid,$sequence)
 {
   mysql_query("INSERT INTO Play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid).
              ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")");
-  return;
+      
+  $playid = mysql_insert_id();
+  return $playid;
 }
 
 function DB_get_all_names_by_gameid($id)
@@ -376,4 +378,10 @@ function DB_get_user_timezone($userid)
   else
     return 0;
 }
+
+function DB_insert_comment($comment,$playid,$userid)
+{
+  mysql_query("INSERT INTO Comment VALUES (NULL,NULL,NULL,$userid,$playid, ".DB_quote_smart($comment).")");
+  return;
+}
 ?>
\ No newline at end of file
index 4a38ed8c9bde2ba498a86c0266c7aab1d9afe85c..6daea5e20ae67dc82332270b7daa195005812b22 100644 (file)
--- a/index.php
+++ b/index.php
@@ -313,6 +313,7 @@ else if(isset($_REQUEST["me"]))
                              "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
                              "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
                              "LEFT JOIN User ON User.id=Hand.user_id ".
+                             "LEFT JOIN Comment ON Play.id=Comment.play_id ".
                              "WHERE Trick.game_id='".$gameid."' ".
                              "ORDER BY Trick.id,sequence ASC");
        
@@ -333,6 +334,7 @@ else if(isset($_REQUEST["me"]))
            $seq   = $r[3];
            $pos   = $r[2];
            $trick = $r[5];
+           $comment = $r[6];
            
            if($trick!=$lasttrick && $seq==1)
              {
@@ -354,8 +356,7 @@ else if(isset($_REQUEST["me"]))
            
            $play[$pos]=$r[0];
            
-           $comment=0;
-           if($comment)
+           if($comment!="")
              echo "        <span class=\"comment\">";
            else
              echo "        <span>";
@@ -364,7 +365,7 @@ else if(isset($_REQUEST["me"]))
            echo $r[1];
            
            /* check for comment */
-           if($comment)
+           if($comment!="")
              echo "<span>".$comment."</span>";
            echo "</span>\n        ";
            
@@ -402,10 +403,6 @@ else if(isset($_REQUEST["me"]))
        else
          $myturn = 0;
 
-       if(isset($_REQUEST["comment"]))
-         {
-       
-         }  
        /* do we want to play a card? */
        if(isset($_REQUEST["card"]) && $myturn)
          {
@@ -428,7 +425,14 @@ else if(isset($_REQUEST["me"]))
                $trickid  = $a[0];
                $sequence = $a[1];
                
-               DB_play_card($trickid,$handcardid,$sequence);
+               $playid = DB_play_card($trickid,$handcardid,$sequence);
+
+               /*check for coment */
+               if(isset($_REQUEST["comment"]))
+                 {
+                   DB_insert_comment($_REQUEST["comment"],$playid,$myid);
+                 };  
+
                echo "<div class=\"card\">";
                echo " you played  <br />";
                display_card($card);