I am fetching data from mysql to a page, i am not sure if the way im doing it is appropiate. I am having trouble with fetching values into sections of the page.
<?php
// Connect to database server
mysql_connect("localhost", "xxx", "xxx") or die (mysql_error ());
// Select database
mysql_select_db("xxx") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM news";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column FirstName (which is now in the array $row)
echo $row['editor_name'] . " " . $row['news_desc'];
echo "<br />";
}
// Close the database connection
mysql_close();
?>
</div> <!-- content #end -->
the database;
the above yields;
I want to do the following; BY: Fadi
echo 'BY' $row['editor_name'] . " " . $row['news_desc'];
echo "<br />";
but it isn't working :( any tips
";` should be `echo 'BY' . $row['editor_name'] . " " . $row['news_desc']; echo "
";` – Jack Apr 01 '12 at 20:24