Announcement

Collapse
No announcement yet.

how to delete??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to delete??

    Anything wrong with my code? i tried to delete when i click the delete button, but when i click on the delete button, instead of delete the record, it will go back to the main page.

    this is the code:

    PHP Code:
    if ($do == 'Delete'
        {    
            for (
    $i=0$i<count($cb) ; $i++)
                {
                    
    $sql "DELETE FROM review WHERE ID = '$ID' AND cat_ID = '$cat_ID' AND status = 'u'";
                    
    $result mysql_query($sql);
                }
        } 
    this is the code for the delete button:
    PHP Code:
    print "<tr align=right><td><input type=submit value=\"Update & Approve!\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\">&nbsp;<input type=submit value=\"Delete\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\"></td></tr>\n"
    pls help!!

  • #2
    echo $do
    what's it print?

    Comment


    • #3
      i tried to echo $do, but nothing appear. tried to put b4 the if statement and after the if statement and even inside the if statement. wat could be wrong? the way i pass the do is incorrect??

      Comment


      • #4
        post wot u got inside the form tag

        Comment


        • #5
          PHP Code:
          print "<form action=\"$script\" method=\"post\">\n"
          actually my code goes like this:

          PHP Code:
          if ($action == 'editUser')         
                      {
                          
          editUser();
                      } 
          and then it will go to the function editUser(), where i have the delete ...

          Comment


          • #6
            so $script=="wotever.php?do=delete&action=EditUser"


            ???

            Comment


            • #7
              still can't delete althought the $do == Delete.

              i pass in my values from here:
              PHP Code:
              print "<td width=25 align=center><a href=\"admin.php?action=editUser&id=".$temp['ID']."&rate=".$temp['rate']."&cat=".$temp['cat']."&subcat=".$temp['subcat']."&title=".$temp['title']."&review=".$temp['review']."&name=".$temp['name']."&world=".$temp['world']."&cat_ID=".$temp['cat_ID']."\"><font face=verdana size=1 color=#ffffff>Edit</font></a></td>\n"
              and then it will call to the function below:

              PHP Code:
              function editUser() 
              {
                      print 
              "<table border=0 cellspacing=0 cellpadding=0 width=100% align=center>\n";
                  print 
              "<tr height=20><td valign=top><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Review Administration Panel</b></font></td><td valign=top align=right>";
                      print 
              "</td></tr>\n";
                  print 
              "<form action=\"$script\" method=\"post\">\n";
                  print 
              "<tr><td colspan=2 valign=middle align=center>\n";
                  echo 
              "$do";
                  if (
              $do == 'Delete'
                  {    
                      for (
              $i=0$i<count($cb) ; $i++)
                          {
                              
              $sql "DELETE FROM review WHERE ID = '$ID' AND cat_ID = '$cat_ID' AND status = 'u'";
                                              
              $result mysql_query($sql);

                              if (
              $result
                              {
                                  print 
              "<font face=\"Verdana\" color=\"#ffffff\" size=2>Record Deleted.</font><br>\n";
                              }
                          }
                  }
                  else
                  {
                      for (
              $i=0$i<count($cb) ; $i++)
                          {
                              
              $sql "UPDATE review SET flag = '1' WHERE ID = '$ID' AND cat_ID = '$cat_ID' AND status = 'u'";
                              
              $result mysql_query($sql);

                              if (
              $result
                              {
                                  print 
              "<font face=\"Verdana\" color=\"#ffffff\" size=2>Record Updated.</font><br>\n";
                              }
                          }
                  }


                  print 
              "<table width=500 border=0 cellspacing=1 cellpadding=0 align=center>\n";
                  print 
              "<tr><td align=center><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Edit User Review</b></font></td></tr>\n";
                  print 
              "<tr><td>&nbsp;</td></tr>";
                  print 
              "<tr><td>\n";
                  print 
              "<table width=100% border=0 cellspacing=0 cellpadding=0>\n";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2>&nbsp;</td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2><b>On a scale of 1 to 5, with 5 stars being the best,</b></font>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2>&nbsp;</td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td width=60%><font face=\"Verdana\" color=\"#ffffff\" size=2>1. How do you rate this page?</font></td>";
                  print 
              "<td width=40% align=left><font face=\"Verdana\" color=\"#ffffff\" size=2>";
                  print 
              "<select size=1 name=rate align=center>";

                  for (
              $i=1$i<6$i++)
                  {
                      if (
              $rate == $i)
                          print 
              "<option value=$i selected>$i stars</option>";
                      else
                          print 
              "<option value=$i>$i stars</option>";
                  }

                  print 
              "</select></font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>2. Please enter a title for your review:</font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>&nbsp;&nbsp;&nbsp;";
                  print 
              "<input type=text name=title size=67 value=\"$title\">";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>3. Type your review in the space below:</font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>&nbsp;&nbsp;&nbsp;<textarea rows=5 name=review cols=58>$review</textarea></font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>4. Display this information with your review:</font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td width=20%><font face=\"Verdana\" color=\"#ffffff\" size=2>&nbsp;&nbsp;&nbsp;<input type=radio value=tname ";
                  if (
              $name != "anonymous")
                  {
                      print 
              "checked"
                      
              $yrname $name;
                  }
                  print 
              " name=name>Your name:</font></td>";
                  print 
              "<td width=80% align=left><font face=\"Verdana\" color=\"#ffffff\" size=2><input type=text name=yrname size=25 value=\"$yrname\"></font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>&nbsp;&nbsp;&nbsp;<input type=radio value=anonymous name=name ";
                  if (
              $name == "anonymous")
                  {
                      echo 
              "checked";
                  }
                  print 
              ">Keep me anonymous</font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>5. Where in the world are you?</font>";
                  print 
              "<font face=\"Verdana\" color=\"#ffffff\" size=1>(Eg. US)</font></td></tr>";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2><font face=\"Verdana\" color=\"#ffffff\" size=2>&nbsp;&nbsp;&nbsp;";
                  print 
              "<input type=text name=world size=67 value=\"$world\"></font></td></tr>\n";
                  print 
              "<tr bgcolor=#9999ff><td colspan=2>&nbsp;</td></tr>";
                  print 
              "</td></tr></table>\n";
                  print 
              "<tr><td>&nbsp;</td></tr>";
                  print 
              "<tr align=right><td><input type=submit value=\"Update & Approve!\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\">";
                  print 
              "&nbsp;<input type=submit value=\"Delete\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\"></td></tr>\n";
                  print 
              "</td></tr></table>\n";
                  print 
              "<input type=hidden name=action value=\"editUser\">\n";
                  print 
              "<input type=hidden name=do value=\"Update & Approve!\"\n";
                  print 
              "<input type=hidden name=do value=Delete>\n";
                  print 
              "</form>\n";
                  print 
              "</table>\n";

              Comment


              • #8
                try using $id instead of $ID and make sure all the rest of the variables are in the right case

                Comment


                • #9
                  cuzz you using a function it can't see the global variables

                  try something like:

                  Code:
                  function editUser() 
                  {
                  global $do, $ID, $cat_ID; // and any other global variables you wanna use
                  Last edited by G0D; Mon 19 Nov '01, 6:21am.

                  Comment


                  • #10
                    I also posted at TWF...
                    PHP Code:
                        print "<tr align=right><td><input type=submit value=\"Update & Approve!\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\">";
                        print 
                    "&nbsp;<input type=submit value=\"Delete\" name=do style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\"></td></tr>\n";
                        print 
                    "</td></tr></table>\n";
                        print 
                    "<input type=hidden name=action value=\"editUser\">\n";
                        print 
                    "<input type=hidden name=do value=\"Update & Approve!\"\n";
                        print 
                    "<input type=hidden name=do value=Delete>\n"
                    You are passing 3 values for $do. The two hidden fields, and which ever submit button you press.

                    Comment


                    • #11
                      u shudnt use hidden fields for stuff like that, u can do it thru the form action

                      Comment


                      • #12
                        I always use hidden files. But that's not the point here. The point is that $do is the var that determines what happens next. You want the value from the submit buttons, not the hidden fields or form action.

                        Comment

                        Loading...
                        Working...
                        X