Reply to Re: select on updated value during the fetch

Your name:

Reply:


Posted by Kimmo Laine on 10/07/18 11:50

<cdtsly@relayeur.com> wrote in message
news:1150444378.177655.41090@c74g2000cwc.googlegroups.com...
> Hi i have a table with all value at 4
> i select all lines in a fetch
> i update one with a value of 7

This is where it goes wrong. You update nothing, see explanation below.

> i update all the row in the fetch with a value 5
>
> the result is that all my row are at 5
> and the only line which should be at 7 is at 5 too.
>
> i see that the problem is at the first mysql_db_query, and i don t know
> how to solve it
>
> thanks
>
>
> $query="SELECT * FROM val WHERE str='4'";
> $result=mysql_db_query($datamysql,$query);
> $query7="UPDATE val SET str='7',updated='1' WHERE val='2'";

You update all rows whose val=2 (should this be 4 maybe?), that is none,
because all rows val=4. Nothing is updated. Even if it was, the old record
that you fetched earlier are intact, only the database is updated but the
updates do not reflect on already fetched records. So when you select
something, then update something, the old values are still inside $result,
so the updating means nothing again.

> $result7=mysql_db_query($datamysql,$query7);
>
> while ($row=mysql_fetch_array($result))
> {
>
> $str=$row["str"];
> $val=$row["val"];
> $query2="UPDATE val SET str='5' WHERE val='$val'";
> $result2=mysql_db_query($datamysql,$query2);
>
>
> }
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация