Could someone please help me with this. I'm not getting an error message only a blank page.
Shouldn't this be displaying every row in column fullName?
Shouldn't this be displaying every row in column fullName?
<?php
mysql_connect("host", "username", "password") or die(mysql_error("Could not connect to server."));
mysql_select_db("databasename") or die(mysql_error("Could not select database."));
$query="SELECT * FROM `tablename`";
$result= mysql_query($query) or die(mysql_error("Could not process query."));
while($row=mysql_fetch_array($result) or die(mysql_error("Could not display results."))
{
echo "Name:".$row['fullName'];
}
?>
Hi status260,
Rewritten in Joomla! code
Bob
Rewritten in Joomla! code
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__tablename`;
";
$db->setQuery($query);
$data = $db->loadAssocList();
foreach ( $data as $d ) {
echo 'Name: '.$d['fullName'];
}
?>Bob
while($row=mysql_fetch_array($result) or die(mysql_error("Could not display results."))
{
echo "Name:".$row['fullName'];
}
should be
while($row=mysql_fetch_array($result)
{
$fullName = $row['fullName'];
echo "$fullName";
}The $result variable is already checking for an error.
This topic is locked and no more replies can be posted.
