Jump to content

update multiple rows for records of certain values from an array


vladj

Recommended Posts

Hi,

 

I need to update speciffic dates from a table yyyy-mm-dd, for records with id from the array ('101','107','111').

I have defined the array. I execute the mysql query and obtain the needed dates as an array, and then I need to use those dates to update other records, that have no dates yet, but have ids from the previous array.

Sorry I'm a newbie, don't know to advance further.

 

$id_s=array('113','114');

$sql="select distinct date,id  from calendar where date>'".$year."-11-14' and dayofweek(date)=1 and month(date)=11";

$result=mysql_query($sql);

while ($rows=mysql_fetch_array($result))

{

echo $rows['datea'];

}

 

This gives me the array of dates. The values form the first array, are actually present in the table, but with no date.

 

So then I need to

 

$update = "update calendar set date=" . $rows['date'] ."' where id=$id_s";

 

That is I need to update the table record with the first id in the array with the first date obtain from the previous query. The second id, with the second date...and so on.

I have no clue how to do this.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.