Activity Stream
48,167 MEMBERS
64245 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1.     
    #1
    Member
    Website's:
    itleech.com fixdownloads.com downtoolz.com itcoder.us

    Default Little help in SQL

    i am trying to edit 3 value from 7 values on a mysql table . But seems not working. Do i need to edit all values ?

    using simple update command and using forms to put data.
    SaKIB Reviewed by SaKIB on . Little help in SQL i am trying to edit 3 value from 7 values on a mysql table . But seems not working. Do i need to edit all values ? using simple update command and using forms to put data. Rating: 5
    Signature too big, removed by Staff

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Nah! You need not update all values.

    Could you post the code or something similar which is having same problem?

  4.     
    #3
    Just Another Coder
    I think u should use something like this?

    update tablename set column=value where uniquecolumn = value;

    I hope you got what I wanted to say? Do it one by one and you will get it

  5.     
    #4
    Member
    Website's:
    itleech.com fixdownloads.com downtoolz.com itcoder.us
    I am trying but. it says working fine but now . ok here is the codes

    Code: 
    <?php
    $host="localhost"; // Host name 
    $username=""; // Mysql username 
    $password=""; // Mysql password 
    $db_name="test"; // Database name 
    $tbl_name="test_mysql"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    ?>
    <table width="400" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <table width="400" border="1" cellspacing="0" cellpadding="3">
    <tr>
    <td colspan="4"><strong>List data from mysql </strong> </td>
    </tr>
    
    <tr>
    <td align="center"><strong>Username</strong></td>
    <td align="center"><strong>EMAIL</strong></td>
    <td align="center"><strong>PASS</strong></td>
    <td align="center"><strong>Update</strong></td>
    </tr>
    <?php
    while($rows=mysql_fetch_array($result)){
    ?>
    <tr>
    <td><? echo $rows['username']; ?></td>
    <td><? echo $rows['password']; ?></td>
    <td><? echo $rows['email']; ?></td>
    
    // link to update.php and send value of id 
    <td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
    </tr>
    <?php
    }
    ?>
    </table>
    </td>
    </tr>
    </table>
    <?php
    mysql_close();
    ?>


    Code: 
    <?php
    $host="localhost"; // Host name 
    $username=""; // Mysql username 
    $password=""; // Mysql password 
    $db_name="test"; // Database name 
    $tbl_name="test_mysql"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // get value of id that sent from address bar
    $id=$_GET['id'];
    
    
    // Retrieve data from database 
    $sql="SELECT * FROM $tbl_name WHERE id='$id'";
    $result=mysql_query($sql);
    
    $rows=mysql_fetch_array($result);
    ?>
    <table width="400" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <form name="form1" method="post" action="update_ac.php">
    <td>
    <table width="100&#37;" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>&nbsp;</td>
    <td colspan="3"><strong>Update data in mysql</strong> </td>
    </tr>
    <tr>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    </tr>
    <tr>
    <td align="center">&nbsp;</td>
    <td align="center"><strong>UserName</strong></td>
    <td align="center"><strong>Password</strong></td>
    <td align="center"><strong>Email</strong></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="center"><input name="username" type="text" id="username" value="<? echo $rows['username']; ?>"></td>
    <td align="center"><input name="password" type="text" id="password" value="<? echo $rows['password']; ?>" size="15"></td>
    <td><input name="email" type="text" id="email" value="<? echo $rows['email']; ?>" size="15"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
    <td align="center"><input type="submit" name="Submit" value="Submit"></td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>
    
    <?
    
    // close connection 
    mysql_close();
    
    ?>


    Code: 
    <?php
    $host="localhost"; // Host name 
    $username=""; // Mysql username 
    $password=""; // Mysql password 
    $db_name="test"; // Database name 
    $tbl_name="test_mysql"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // update data in mysql database 
    $sql="UPDATE $tbl_name SET username='$username', password='$password', email='$email' WHERE id='$id'";
    $result=mysql_query($sql);
    
    // if successfully updated. 
    if($result){
    echo "Successful";
    echo "<BR>";
    echo "<a href='list_records.php'>View result</a>";
    }
    
    else {
    echo "ERROR";
    }
    
    ?>

    IT SAYS THAT WORK DONE> BUT DOESN"T CHANGE THE VALUE IN MYSQL
    Signature too big, removed by Staff

  6.     
    #5
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    maybe you have an error there
    replace
    $result=mysql_query($sql);
    with
    $result=mysql_query($sql) or die(mysql_error());

  7.     
    #6
    Member
    Website's:
    itleech.com fixdownloads.com downtoolz.com itcoder.us
    @ t3od0r yes but it will show it works or not. i am trying get it working
    Signature too big, removed by Staff

  8.     
    #7
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    SET username='$username', should be SET username='".mysql_real_escape_string($_POST['username'])."',

    i don't see any $_POST in your update file

  9.     
    #8
    Member
    Website's:
    itleech.com fixdownloads.com downtoolz.com itcoder.us
    Just editing that line will work ?

    IF yes tell me will check now
    Signature too big, removed by Staff

  10.     
    #9
    Respected Member
    That is a real mish mash of code.

    Looks like you are using the same db/table for all of it. You read an id and the user, pswd & email then pass the exact same data to be updated to itself.

    Where is anything changing?

  11.     
    #10
    Member
    // get value of id that sent from address bar
    $id=intval($_Post['id']);
    $username = $_Post['username'];
    $password = $_Post['password'];
    $email = $_Post['email'];

    For inserted/updated data use mysql_real_escape_string


Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

BE SOCIAL