Jump to content

Echo Specific Column


Solar

Recommended Posts

Say I have a forum with tables that look like this in the mysql database;

 

fidforumdesccat

1GeneralTalk About Anythinggeneral

2HobbiesTalk About Hobbiesgeneral

3HTML HelpGet help on HTMLhelp

 

How can I use this;

$sql="SELECT * FROM $tbl_name ORDER BY fid";

By grabbing just the one column for example general?

 

Thanks.

Link to comment
Share on other sites

$sql="SELECT '<column_name>' FROM $tbl_name ORDER BY fid";

for instance

$sql="SELECT 'forum' FROM $tbl_name ORDER BY fid";

and if you want more than one column, concatenate them with a comma:

$sql="SELECT 'fid', 'forum' FROM $tbl_name ORDER BY fid";

Why did you place the column names in quotes? That's not needed, perhaps you meant to use backticks (`)? Backticks aren't even required, and not suggested, unless you're using reserved words for your column names which you really shouldn't be doing in the first place.

Link to comment
Share on other sites

Why did you place the column names in quotes? That's not needed, perhaps you meant to use backticks (`)? Backticks aren't even required, and not suggested, unless you're using reserved words for your column names which you really shouldn't be doing in the first place.

 

you are right...

they are not needed...

sorry about that

 

 

Link to comment
Share on other sites

Oops, I understand that. Doh, silly me.

 

I know how to echo the specific column, what I meant was...

 

Echo the table I provided (Which I have coded) but only show the forum with the specific category for example;

 

fidforumdesccat

1GeneralTalk About Anythinggeneral

2HobbiesTalk About Hobbiesgeneral

3HTML HelpGet help on HTMLhelp

 

Will result into php coding;

fidforumdesccat

1GeneralTalk About Anythinggeneral

2HobbiesTalk About Hobbiesgeneral

 

<td bgcolor="#FFFFFF"><? echo $rows['forum']; ?><BR><span class="style1"><? echo $rows['desc']; ?></span></td>

 

But using;

$sql="SELECT * FROM $tbl_name ORDER BY fid";

Do I use a whereas in this statement?

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.