Reply
last id in update operation
Old 04-30-2007, 03:52 AM last id in update operation
Experienced Talker

Posts: 33
Name: subhash garai
/*============================= check for presence of bid from this seller=========================*/
$stmt="SELECT * FROM `bidding` WHERE `proj_id`='$id' AND `seller_id`='$row[id]'";
$res_bid=mysql_query($stmt);
$row_bid=mysql_fetch_array($res_bid);
$num=mysql_num_rows($res_bid);

if($num)
{
//update present bid data
$sql_update="UPDATE `bidding` SET `proj_id`='$id',`seller_id`='$row[id]',`seller_name`='$user',`bid_amount`='$amount',`ti meframe`='$days',`bid_time`='$bid_time',`bid_date` ='$date',`bid_details`='$details',`bid_notify`='$n otify',`bid_status`='0' WHERE `proj_id`='$id' AND `seller_id`='$row[id]'";
$res_update=mysql_query($sql_update)
or die("Could not update data".mysql_error());
$msg="Your bid has been successfully UPDATED";
header("location:confirmation.php?msg=$msg");
}
else
{
//insert first bid data
$qry="INSERT INTO `bidding` VALUES('','$id','$row[id]','$user','$amount','$days','$bid_time','$date','$ details','$notify','0')";
$result=mysql_query($qry)
or die("Could not insert data".mysql_error());
$msg="Your bid has been successfully recorded";
header("location:confirmation.php?msg=$msg");
}




------------------ Please suggest me how can i get the last inserted id in updation.
subhash_garai is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-30-2007, 05:32 AM Re: last id in update operation
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
Meh ???
Don't you actually get it to specify which record to update ?
Don't know if you talk about the proj_id or the seller_id though.

Simply keep that id in a separate variable...
On each update, the variable will be updated with the last id that have been updated.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-30-2007, 06:34 AM Re: last id in update operation
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
you can ever do a mysql_insert_id function but that will only return for an insert opereation

or you could make you're own function let's say
PHP Code:
function mysql_last_id($table){
    
$sql="SELECT max(id) as last_id FROM `$table` ";
    
$res=mysql_query($sql);
    
$row=mysql_fetch_array($res);

return 
$row['last_id'];

Hope it helps
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-30-2007, 07:23 AM Re: last id in update operation
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
The facti is that he don't want to get a insert id, but an update id, which is rather strange, as you have to know which record you want to update, thus the id of this record.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-30-2007, 07:25 AM Re: last id in update operation
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
in that case you just do a select id from the table with the where conditions from the update
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-30-2007, 07:31 AM Re: last id in update operation
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
yeah, but he already have it, as he just did an update !!!
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-30-2007, 08:02 AM Re: last id in update operation
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
now that i had a better look you are right ...
he has the $row_bid array that contains his id
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Reply     « Reply to last id in update operation
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.36337 seconds with 13 queries