Jump to content

[SOLVED] Mysql and deincrement


spfoonnewb

Recommended Posts

Can anyone help me get this code working, I need it to select each row that isn't equal to zero, and subtract one from it...

 

<?php 

//Db info

	$result = mysql_query("SELECT cst FROM my_db WHERE cst != '0'") or die(mysql_error());  

	while($row = mysql_fetch_array( $result )) {

		$stamp[] = $row['cst'];
		$stamp[]--;
		mysql_query("UPDATE my_db SET cst = '$stamp[]'") or die(mysql_error());
	}

?>

Link to comment
https://forums.phpfreaks.com/topic/36595-solved-mysql-and-deincrement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.