Alright I am confused. Here is what I got <?php $sql = "SELECT * FROM category WHERE parent = 0"; $result = mysql_query($sql) or die(mysql_error()); while ( $row = mysql_fetch_array($result) ) { $output .= "$row->title"; } return $output; ?> PHP: That isnt working, but it does work if I do this. <?php $sql = "SELECT * FROM category WHERE parent = 0"; $result = mysql_query($sql) or die(mysql_error()); while ( $row = mysql_fetch_array($result) ) { echo $row->title; } ?> PHP: Any idea why? I really need to use it in the first example. Thanks in advance.
Use $output .= "{$row->title}"; php must parse the variables in the double quotes, it does not know if the '-' is part of the variable without the brackets.
tried $output .= "{$row->title}"; and didnt work. I have another script that I did it without the brackets and it works just fine. Not sure what I am missing here.
If the second example of you worked, this must work <?php $sql = "SELECT * FROM category WHERE parent = 0"; $result = mysql_query($sql) or die(mysql_error()); $output = ''; while ( $row = mysql_fetch_array($result) ) { $output .= $row->title; } echo $output; ?> otherwise maybe use $row['title']; (it is an array after all)