Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-08-2012, 01:39 AM   PM User | #1
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Using PHP IF and SQL

Hello , I am trying to achieve something like this :
PHP Code:
cornjob.php

<?php
mysql_query
("SELECT * FROM userinfo WHERE IF timeleft = 0 THEN SET plan=0");

?>
How can I do something like this with PHP or SQL?
Vernk is offline   Reply With Quote
Old 10-08-2012, 03:48 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,661
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You mean like an update query?
Code:
UPDATE userinfo SET plan = 0 WHERE timeleft = 0
?

SQL has its own if/else handling, look into the case syntax. Much like a switch really.
Fou-Lu is offline   Reply With Quote
Old 10-08-2012, 04:44 AM   PM User | #3
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
Well I want it to select the timeleft and if it equals 0 then it will set plan to 0 so some way of doing this
Vernk is offline   Reply With Quote
Old 10-08-2012, 06:49 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,661
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Do you need to make use of them after the fact? You cannot issue a select and an update together (especially not in PHP since they are different DMS'). If you don't need to make use of them, you can simply update. Otherwise, select with a necessary where clause to capture the data, then issue an update.
Unless `plan` isn't a property?
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:30 AM.


Advertisement
Log in to turn off these ads.