The table being used is
tablename: users
user_id (bigint) Primary key (autoicrement)
user_name
user_active
The query that i am executing is
$sql = "SELECT * FROM users";
$ret = mysql_query($sql);
if (mysql_num_rows($ret))
{
while ($row = mysql_fetch_array($ret))
{
$sql_update = "UPDATE users SET user_active = 1 WHERE user_id = ".$row['user_id'];
mysql_query($sql_update);
}
}
When i do that not all records in users table is not getting updated. I tried by fetching 1 record by giving "limit
1" clause as
SELECT * FROM users limit 1. Then it is working fine.
Another problem that I face is with INSERT statement following a deletion from the same table. For example
Table: test
test_id (primary key)
test_name
site_id (foreign key)
When ever INSERT records for any of the value of site_id, all the previous entries for that site_id
from the above table will be deleted and the new values will be inserted after that. The method i follow is as
follows
$site_id = 1;
$sql_del = "DELETE FROM test WHERE site_id = $siteid";
mysql_query($sql_del);
for ($i ......)
{
$name = 'test'.$i;
$sel_insert = "INSERT INTO test SET test_name='$name',site_id=$siteid";
mysql_query($sql_insert);
}
When i perform this what happend is that the delete is not working, but insertion takes place which cause
duplicate values.
Please some one help me.