Current location: Hot Scripts Forums » Programming Languages » PHP » display specific column from mysql table


display specific column from mysql table

Reply
  #1 (permalink)  
Old 11-03-10, 04:32 AM
g.sobhani g.sobhani is offline
New Member
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
display specific column from mysql table

Hi i'm new to php. I've 3 MySQL table and each have same column. i want to display selected data from 3 tables.every table have 50 column. i want to display only selected column.

Have anyone any Idea about it?

Last edited by g.sobhani; 11-03-10 at 04:59 AM.
Reply With Quote
  #2 (permalink)  
Old 11-03-10, 04:48 AM
MrWheezy MrWheezy is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Try to read this, it helped me alot understanding MySQL:

SQL Tutorial - First Program in PHP and MySQL

PHP Code:

$command="SELECT * FROM houses WHERE apartment = 2";

$result mysql_query($command$connection); 
Reply With Quote
  #3 (permalink)  
Old 11-03-10, 05:03 AM
g.sobhani g.sobhani is offline
New Member
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by MrWheezy View Post
Try to read this, it helped me alot understanding MySQL:

SQL Tutorial - First Program in PHP and MySQL

PHP Code:

$command="SELECT * FROM houses WHERE apartment = 2";

$result mysql_query($command$connection); 
thanks for your reply but i don't want to select all the columns. I want to SELECT(mysql query) selected column only. user select apartment, name,town then only these field will SELECT in sql query.
Reply With Quote
  #4 (permalink)  
Old 11-03-10, 05:38 AM
MrWheezy MrWheezy is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by g.sobhani View Post
thanks for your reply but i don't want to select all the columns. I want to SELECT(mysql query) selected column only. user select apartment, name,town then only these field will SELECT in sql query.
ok:

PHP Code:

$command="SELECT * FROM houses";

$result mysql_query($command$connection); 
PHP Code:

// Loop through the results

while($row mysql_fetch_array$result )) {
echo 
"<p>;
echo 
$row['town'];
echo "
</p>

Reply With Quote
  #5 (permalink)  
Old 11-03-10, 10:10 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
If you only want the three columns, then put them in your query.
PHP Code:

$command="SELECT apartment,name,town FROM houses WHERE apartment = 2";
$results mysql_query($command);
while(
$row mysql_fetch_assoc($results))
{
 echo 
$row["apartment"]." ".$row["name"]." ".$row["town"]."<br />";
 } 
But if you want the whole record and then display the three columns only, then do something like this:
PHP Code:

$command="SELECT * FROM houses WHERE apartment = 2";
$results mysql_query($command);
while(
$row mysql_fetch_assoc($results))
{
 echo 
$row["apartment"]." ".$row["name"]." ".$row["town"]."<br />";
 } 
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks

Tags
mysql, php, specific column data


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Pulling user specific data in Php through MySQL JDigital PHP 8 06-03-08 05:28 PM
Syntax Error Nikas Database 4 05-15-08 10:48 AM
CSS Column Display - IE 5.5+ Metic CSS 2 02-07-08 03:32 AM
Pull specific data from flat file and display Andy128 PHP 2 04-24-07 08:33 PM
Unknown table in MySql where clause greymoose Database 2 09-13-06 11:49 PM


All times are GMT -5. The time now is 08:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.