Jump to content

Archived

This topic is now archived and is closed to further replies.

nadz

sql query to show only some fields

Recommended Posts

hi, i need an sql query i can execute in a table so that it only shows 2 of the fields. any help would be appreciated. thankyou.

Share this post


Link to post
Share on other sites
In php:
[code]
<?php

$select = mysql_query("SELECT field_1, field_2 FROM table") or die(mysql_error());
while($col = mysql_fetch_array($select, MYSQL_ASSOC)
{
foreach($col as $fieldname => $value)
{
${$fieldname} = $value;
}

echo $field_1;
echo $field_2;
}

?>
[/code]

Share this post


Link to post
Share on other sites
hi, thanks alot for your help  ;)

unfortunately im getting errors. im using phpmyadmin, the 2 fields i want to see are "members" and "date" in the table "users". i hope this helps.

thanks again for the help.

Share this post


Link to post
Share on other sites
DATE is a reserved keyword -- change your column name; in the meanwhile, you can use `date`.

Share this post


Link to post
Share on other sites

×

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.