Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

How to change a single users details in Mysql and php

0

63 views

Hey i need to change a users info but only one users info so for instance.

id    username     password      Intro
1       Ryan         ****          1

I need to change only the Intro part? i hope this will be changed when the user goes through the intro and then goes to a page where the users Intro will change to 2 to mean yes he has gone through the intro..

and also if it helps my database name is users

asked May 16, 2011 3:16 am CDT
posted via StackOverflow

5 Answers

0
 

Send an SQL query like:

update users set Intro=2 where id=1;

answered May 16, 2011 3:23 am CDT
ADW
0
 

This?

UPDATE users SET intro = 1 WHERE id = 2

answered May 16, 2011 3:23 am CDT
0
 
UPDATE users SET Intro = 2 WHERE id = 'yyy'

You need to set yyy to the ID of the logged in user

answered May 16, 2011 3:23 am CDT
1
 

Assuming your user table has primary key id, below code will give u an idea.

<?php
$server = ''; // server where your db is hosted
$username = ''; //username of the database
$password = ''; //password of the database
$dbname = ''; //database name of the server
$id = ''; //id of the user you want to change the intro flag of

$vlink = mysql_connect($server,$username,$password);
$dbselect = mysql_select_db($dbname);

//assuming the user already has a row in the table...
$query = 'SELECT COUNT(*) FROM user where id = "'. $id . '" and intro = 1';

$result = mysql_query($query,$vlink);

if(mysql_num_rows($result)>0)
    echo 'User has already been through intro';
else
{
    $query = 'UPDATE users SET intro = 2 WHERE id = ' . $id;

    $result = mysql_query($query,$vlink);
    if($result)
        echo 'Success';
    else
        echo 'Failed...!';
}
?>

answered May 19, 2011 1:28 pm CDT
1
 

Something like this?

$id = (int) $id;
mysql_query("update users set intro = 2 where users.userid = $id;");

It's probably worth running through some MySQL tutorials to give you some of the basics.

answered May 19, 2011 1:28 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
MongoDB Query Details
January 19, 2011