Hey im looking for a SQL statement that let me alters the int in the database to a zero for inactive - i have no idea how to write the SQL query like that,and how the php code would look.
This is my best guess..
select id,active
from posts
where id = '42' and (active = '1')
This is the current statement, well '42' is a var in the php i can find the current row and it prints out this
id active
42 1
in the sql database - how can i alter the int to a zero?
You have to use the UPDATE
command to update the rows already in the database. That UPDATE command execute against some key for eaxmple in your example that is ID
.
The UPDATE Command syntax will be like this:-
UPDATE tablename SET columnWhichNeedsTObeUpdated = newValueforColumn
WHERE KeyColumn = KeyColumnIdentifierValue
For eaxmple for your case:-
UPDATE posts SET active = 0
WHERE id = 42