Jump to content

Recommended Posts

Hello.

This is the current code:

$table = 'core_members';
$query = \IPS\Db::i()->select('*', $table, 'name=' . "'$username'")->query;
$result = \IPS\Db::i()->query($query)->fetch_assoc();

 

and then i can use

$id = $result["member_id"]; // member id

to get the member id of the username i entered.

 

However, how do i change the member id?

I can get the member id by using the code above of the user i want, but i want to be able to change it. Please help with that.

 

To clarify, i can get the values i want, but i want to be able to change them as well.

Link to comment
https://forums.phpfreaks.com/topic/314153-help-needed-mysql-php/
Share on other sites

39 minutes ago, longjohn said:

but i want to be able to change it

No, you really don't. That is path to disaster in a relational database where entities are related by their ids.

As a rule, don't change, delete or re-use ids.

1 hour ago, longjohn said:

However, how do i change the member id?

Why do feel the you want to do this? 
Whatever the reason, it's almost certainly misguided. 

As Barand said, the unique identifier for each record should be generated when that record is created and should then persist, unchanged, until that record (and all the other records related to it) are finally and forever deleted. 

Can you imagine the chaos if your bank renumbered all of its accounts every time someone else closed their account? 

Regards,
   Phill  W.

 

7 hours ago, ginerjm said:

What kind of code is this?  I do not recognize your syntax.  Is this from some framework perhaps?

This is manipulation of the Invision(company that makes our forum, which was formerly known as IPBoard) framework for doing things with Invision community (the suite of stuff that includes what was once IPboard).

7 hours ago, longjohn said:

Hello.

This is the current code:

$table = 'core_members';
$query = \IPS\Db::i()->select('*', $table, 'name=' . "'$username'")->query;
$result = \IPS\Db::i()->query($query)->fetch_assoc();

 

 

 

Changing something is fairly trivial, but as this hits close to home for us, what exactly is it that you are trying to do, and why?  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.