Results 1 to 10 of 14
-
15th Apr 2011, 04:40 PM #1OPMemberWebsite's:
itleech.com fixdownloads.com downtoolz.com itcoder.usLittle 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: 5Signature too big, removed by Staff
-
15th Apr 2011, 04:55 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inNah! You need not update all values.
Could you post the code or something similar which is having same problem?
-
15th Apr 2011, 05:07 PM #3Just 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
-
15th Apr 2011, 05:28 PM #4OPMemberWebsite's:
itleech.com fixdownloads.com downtoolz.com itcoder.usI 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%" border="0" cellspacing="1" cellpadding="0"> <tr> <td> </td> <td colspan="3"><strong>Update data in mysql</strong> </td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </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> </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> </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> </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 MYSQLSignature too big, removed by Staff
-
15th Apr 2011, 05:31 PM #5MemberWebsite's:
wscripts.net damnlolscript.com lulzjet.commaybe you have an error there
replace
$result=mysql_query($sql);
with
$result=mysql_query($sql) or die(mysql_error());
-
15th Apr 2011, 05:34 PM #6OPMemberWebsite'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
-
15th Apr 2011, 05:38 PM #7MemberWebsite's:
wscripts.net damnlolscript.com lulzjet.comSET username='$username', should be SET username='".mysql_real_escape_string($_POST['username'])."',
i don't see any $_POST in your update file
-
15th Apr 2011, 05:40 PM #8OPMemberWebsite's:
itleech.com fixdownloads.com downtoolz.com itcoder.usJust editing that line will work ?
IF yes tell me will check nowSignature too big, removed by Staff
-
15th Apr 2011, 09:07 PM #9Respected 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?
-
16th Apr 2011, 12:42 AM #10Member
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
themaCreator - create posts from...
Version 3.52 released. Open older version (or...