|
-
Jun 26th, 2002, 03:41 AM
#1
Thread Starter
Hyperactive Member
When Insert .. but what when Update ?
In this code:
$Sql = "INSERT INTO Subject (ReplyNo) VALUES ('0')";
$Result = mysql_query($Sql);
Echo mysql_insert_id();
I use ( Echo mysql_insert_id(); ) to echo the the current ID that Inserted
but what can I use to know the current ID that updated ??
I try that
$Sql = "UPDATE Main SET tt='$tt' WHERE MainID=$MainID";
$Result = mysql_query($Sql);
Echo mysql_update_id();
but give me error that (there is not any function like that (mysql_update_id()
-
Jun 26th, 2002, 05:44 AM
#2
Addicted Member
I'm not sure there is a function for that. There is a function mysql_affected_rows() which returns how many records were updated/deleted. If you were doing an update with just one record, you could make sure it went through alright, you could use this to check it.
-
Jun 26th, 2002, 09:30 AM
#3
Thread Starter
Hyperactive Member
V.G TheGoldenShogun
Thank you too much TheGoldenShogun !! that is what I need..
-
Jul 1st, 2002, 08:39 PM
#4
Member
Also, if you don't want to add a duplicate row, you can use:
-
Jul 1st, 2002, 09:53 PM
#5
Junior Member
I would honestly do it like this:
PHP Code:
$query = "SELECT * FROM table";
$result = mysql_query($query, $connect);
while($curr_id = mysql_fetch_array($result))
{
$id_count = $cur_id[id]; // This is the long way...
}
// $id_count is equal to the last id in the db!
-
Jul 1st, 2002, 09:56 PM
#6
Member
How about:
Code:
SELECT id FROM table ORDER BY id ASC LIMIT 1
-
Jul 1st, 2002, 09:58 PM
#7
Junior Member
that would work also, I like to take all my data out, because I usually it...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|