Jump to content

How can I get this piece of code too work?


xwishmasterx

Recommended Posts

I have this little code that I cannot get to work

$sql_buildings = ("SELECT castle, treasury, huts, [b]leader_id[/b] FROM teams WHERE team_id=[b]".$_GET['t']." [/b]");
$rsbuildings = mysql_query($sql_buildings);

if($rsbuildings[".$_GET['t']."] == 'leader_id' ){

 

The problem is this part:

if($rsbuildings[[b]".$_GET['t']."[/b]] == '[b]leader_id[/b]' ){

 

How can I write it to have these to values work?

Before you can access the row your mysql_query matched, you have to fetch one using one of the mysql_fetch functions. For example, mysql_fetch_array will return an array of the row with the array keys being the field names of your row. So if you called this:

$row = mysql_fetch_array($rsbuildings);

$row would then contain this:

$row['castle'] => castle value
$row['treasury'] => treasury value
$row['huts'] => huts value
$row['leader_id'] => leader_id value

You'll have to explain what you're trying to do if you want us to actually help with the code.

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.