• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Mysql database: Editing values in the table help

XeonGX

New Member
Hello everyone,
I've got a mysql table, with fields in it.

User_____Pass_____Email_____Type
1 1 _____ 1 1 _____ 1 1 _____ 0
1 1 _____ 1 1 _____ 1 1 _____ 0
1 1 _____ 1 1 _____ 1 1 _____ 0
1 1 _____ 1 1 _____ 1 1 _____ 0

and i want to change all the values under the Type field into 1 instead of 0.
its pretty hard to do it manually cuz there is 1000+ values to edit,
can you guys write a code to do this?
:fangel: thank you
 
PHP:
<?
mysql_connect( "hostname", "username", "password" );
mysql_select_db( "database" );
$result = mysql_query( "UPDATE `tablename` SET type = '1' WHERE type = '0'"  );
if( $result ):
printf( 'Query executed, affected %d rows', mysql_num_rows( $result ) );
else:
die( mysql_error() );
endif;
 
Last edited:
@krakjoe
UPDATE `tablename` SET type = '1' WHERE type = '0'
depend of the type of 'type' field i think. It may work in mysql lately, but i have some problem (3-4 years ago) when 'type' field is numeric. If type of 'type' field is numeric i prefer to :
UPDATE `tablename` SET Type = 1 WHERE Type = 0
 
Last edited:
Back
Top