SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jun 8, 2007, 07:17 #1
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How do I word my php update statement?
I need to say something like the following, not sure how to do it though:
PHP Code:<?php
mysql_query (update table set lockedstatus='LOCKED' where username="all usersnames located in table");
?>
-
Jun 8, 2007, 07:28 #2
- Join Date
- Feb 2005
- Location
- Universum, 3rd Corner
- Posts
- 3,000
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
So basically, you want to update ALL entries?
In that case, you don't need where part.-- Jelena --
-
Jun 8, 2007, 07:37 #3
- Join Date
- Mar 2002
- Location
- Whistler, Canada
- Posts
- 51
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:mysql_query (update table set lockedstatus='LOCKED' where username="all usersnames located in table");
Mind the quotes, the query is a string:
PHP Code:mysql_query("update table set lockedstatus='LOCKED'");
Pepe
-
Jun 8, 2007, 07:38 #4
- Join Date
- Apr 2007
- Posts
- 690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay great thanks so much. Another quick question though, I need to say something like the following:
Select username from table where
department = variable
department2 = variable
etc
-
Jun 8, 2007, 07:44 #5
- Join Date
- Apr 2006
- Location
- Pennsylvania
- Posts
- 1,736
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You know there is a mysql forum, right?
Anyway, in that case you'd use the AND operator between the two parts of the where clause.
-
Jun 8, 2007, 22:40 #6
- Join Date
- Jan 2002
- Location
- Australia
- Posts
- 2,634
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You construct MySQL queries as normal strings, meaning you can concatenate (.) or place (properly validated) variables in a double quoted strings to construct the string dynamically.
You then just send that string to mysql via mysql_query or mysqli_query
Bookmarks