0

hi all,
i need to echo the value obtained in the mysql query. so can any one ..
Thank u..

$sql2="select reportingto from users where username='$_SESSION[username]'";
   mysql_error();
   $result2 = mysql_query($sql2);
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by niths
0

Just want to echo, or not getting the result from the sql query.

echo $result2;

as almostbob suggested
or use

print $result2;
0

Just want to echo, or not getting the result from the sql query.

echo $result2;

as almostbob suggested
or use

print $result2;

i got it as 'Resource id #4'
i think we need to use some thing like 'mysql_fetch_array'

0

Point out clearly nith, ok let take a look at below and change over to your code

$query = "SELECT * FROM symbols"; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
while($row = mysql_fetch_row($result)) { 
echo $row[0];
}
}

This will output your first field in your databse, use $row[1],$row[2] etc.

Edited by rajarajan07: n/a

0

Point out clearly nith, ok let take a look at below and change over to your code

$query = "SELECT * FROM symbols"; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
while($row = mysql_fetch_row($result)) { 
echo $row[0];
}
}

This will output your first field in your databse, use $row[1],$row[2] etc.

ha ha i got it... thank u. and that sorry for my poor english...

This question has already been answered. 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.