Jump to content

[SOLVED] A little help with sql


weeder

Recommended Posts

using mccodes

I trying to add a country flag to another page depending on which country they are in.

Here is where i am so far

$ct= mysql_fetch_object(mysql_query("SELECT coun_flag FROM countries WHERE coun_id = '{$ct['country']}'"));
echo "<center><img src='{$ir['coun_flag']}' width='50' height='50'><br /><br />

 

and get a error off this line

echo "<center><img src='{$ir['coun_flag']}' width='50' height='50'><br /><br />

 

can anyone help

 

many thanks in advance

Link to comment
Share on other sites

And it explains a lot

 

First you use mysql_fetch_object to get data from database loaded into object $ct

 

Then you try to use it as an array... makes no sense

 

To access data in object use:

(where is $ir defined by the way? it's not in the code you posted)

$ir->coun_flag

Link to comment
Share on other sites

ok users can go to different countries

The datatable table is countries and there is a image url stored in coun_flag.

The table that stores which country the user is in is the users database in column country.

 

I am trying to get the image of which country they are in to show on a sidemenu.

 

I think i have the mysql_fetch_object right but its the array thats got me.

 

But being new on php I have tried all i can think of and now lost, I hope this helps, can't think of another way to explain

Link to comment
Share on other sites

Sloved

 

$ct = mysql_query("SELECT `coun_flag` FROM `countries` WHERE `coun_id` = '{$ir['country']}'") or die (mysql_error());
$ct = mysql_fetch_object($ct);
echo '<center><img src="' . $ct->coun_flag . '" width="50" height="50"></center><br />';

 

Thanks a lot for your help

Link to comment
Share on other sites

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.