0

I want to select a single column from a table but cannot use "mysql_result" query. is there any other way to output the data of that specific column?

Thanks in advance.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by vaultdweller123
0
$sql = mysql_query("SELECT any_column FROM yourtable")
while($row=mysql_fetch_array($sql)){
echo $row['any_column'];
}

Edited by vaultdweller123: n/a

0
$query = "SELECT country FROM symbols";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
 echo "column selected";
} else echo "no column selected"
0
$sql = mysql_query("SELECT any_column FROM yourtable")
while($row=mysql_fetch_array($sql)){
echo $row['any_column'];
}

thanks for reply, but this will display all the fields from any particular column. i just want a single field.

0

yes we are selecting only a single field which is any_column no other else, FYI the column's are the fields othe table, maybe you mean return a single row? which is the queried recordset

then limit it with a WHERE clause, like

$sql = mysql_query("SELECT any_column FROM yourtable WHERE id=1")
while($row=mysql_fetch_array($sql)){
echo $row['any_column'];
}

Edited by vaultdweller123: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.