/    Sign up×
Community /Pin to ProfileBookmark

PHP SQL More than one command…..Help

hi guys im making an alliance thing for my game and what it does is when a user creates an alliance i want to record the name of the alliance they typed in(goes into the ”alliance table” and then in ”name”) and the users id into the ”alliance_leader” in the alliance table. plus i want it so when this happens the alliances id is recorded on the users alliance id collum.

This is my database:

[QUOTE]

[B]The databases[/B]———–[B]The columns[/B]
Alliance – ————-ID, name, alliance_leader.

Users —————– ID, name, password, allianceid.

[/QUOTE]

ive done the recording of the name:

[code=php]$update = mysql_query(“Update alliance table set alliance_name = ‘$alliance_name’ where username = ‘$logged[username]'”)
or die(mysql_error());[/code]

can anyone help me to add to it, for it to record the alliance id and leader and the users alliance id.

if you know what im talking about please help:o

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@klaroenFeb 07.2008 — [code=php]
$Insert = @mysql_query("insert into alliance (name,alliance_leader) values ('$alliance_name', '$logged[username]')") or die(mysql_error());
$GetID = @mysql_fetch_array(mysql_query("select id from alliance where alliance_leader='$logged[username]'"));
$AllianceID = $GetID["id"];
$Update = @mysql_query("update Users set allianceid='$AllianceID' where name='$logged[username]'") or die(mysql_error());
[/code]
Copy linkTweet thisAlerts:
@mitchellauthorFeb 07.2008 — thanks allot
×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...