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
https://forums.phpfreaks.com/topic/132735-solved-a-little-help-with-sql/
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

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

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

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.