Jump to content

Recommended Posts

Hi

I want to know how to select columns from mysql usng php. I know I can select columns in mysql using the following statement:

[code]Select column1, column2 from table where company like '%abc%'[/code]

how do i do the same using php, is it going to be:

[code]select '".$_GET['column']."' from table where comapny like '%".$_GET['abc']."%'[/code]

basically I have a survey table with 12 columns, I want users to only search and view columns they want e.g. user1 wants to view companies with higher market position, user2 wants to see brands, companies and display items, user3 wants to see companies with multi branches and their top selling brands.

Is it possible and can someone point me to the right direction.

Thanks in advance
Sab
Link to comment
https://forums.phpfreaks.com/topic/12722-select-columns-using-phpmysql/
Share on other sites

[!--quoteo(post=387330:date=Jun 23 2006, 07:40 PM:name=hackerkts)--][div class=\'quotetop\']QUOTE(hackerkts @ Jun 23 2006, 07:40 PM) [snapback]387330[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This is how you do query in php,
[code]$colunm = $_GET['column'];
$abc = $_GET['abc'];
$query = "select $column from table where comapny like '%$abc%'";
$result = mysql_query($query) or die("Query failed: " . mysql_error());[/code]
[/quote]

Thanks for your help, how do i display selected columns close together. I am dispalying results in a table, when I select 1st and 9th column I get huge space in between how do i get rid of that.

Should be displayed like this:
Search Results
column1 column9
cxc No
gfg No
rtrt No

Thanks
Sab
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.