need sql help

Discussion in 'PHP' started by tweetwap, Mar 1, 2012.

  1. #1
    hey friends


    i want to direct clear a single coloum by user table

    i use to clear a table this via this php code only run code my table clear

    $db->delete_data("DELETE FROM b_vote");

    but dnt knw how to clear a single row or coloum from the table .....

    dnt do via sql database or myphpadmin

    i want put in php script...

    this is my user table

    CREATE TABLE IF NOT EXISTS `users` (
    `userid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `username` text,
    `password` text,
    `email` text,
    `groupid` bigint(20) unsigned NOT NULL DEFAULT '0',
    `rank` varchar(255) NOT NULL DEFAULT '0',
    `vote` bigint(20) unsigned NOT NULL DEFAULT '0',
    PRIMARY KEY (`userid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;


    i want its clear users table all vote count form vote colum or row

    now tell me how i do that


    this is my vote clear code

    PHP Code:
     <?php 
         
        include "include/init.php";  
        if(isloggedin()) 
        { 
            if($group[$user->groupid]['type'] == 3 || $group[$user->groupid]['type'] == 4 ) 
            { 
         
            $db->delete_data( "DELETE FROM users WHERE vote='$vote' "); 
             
            } 
            else 
            { 
                print "You dont have permission for this."; exit; 
            } 
             
        } 
    ?> 
         
        <span style="font:normal 10pt verdana;">Votes Cleared</span><br/><br/> 
         
         
        <a href="../forum/index.php">Back to home</a> <br/> 
      
    
    
    
    
    PHP:
    if i put this


    mysql_query("DELETE FROM users WHERE userid= '$userid'");


    wrk fi9 but when i use


    mysql_query("DELETE FROM users WHERE vote= '$vote'");

    get this

    Notice: Undefined variable: vote in C:\wamp\www\forum\clearvote.php on line 9

    now help me what i do plz
     
    tweetwap, Mar 1, 2012 IP
  2. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is $vote defined? What is the value of $vote since I don't see it defined in the code sample provided.
     
    trendint, Mar 1, 2012 IP