Lets say we have a test database. In the database we have a table named users. The table has 1 column, name.
Instead of using something like
<?php
$sql = mysql_query("SELECT name FROM users WHERE name='abc'");
while ($row = mysql_fetch_array($sql))
{
echo $row['name'];
}
?>
would it be faster to just use...
<?php
$sql = mysql_fetch_array(mysql_query("SELECT name FROM users WHERE name='abc'"));
echo $sql['name'];
?>
To fetch a single persons name? I always figured you would use the while statement if you wanted to echo the entire table...
<?php
$sql = mysql_query("SELECT name FROM users");
while ($row = mysql_fetch_array($sql))
{
echo $row['name'] . "<br/>";
}
?>
Instead of using something like
<?php
$sql = mysql_query("SELECT name FROM users WHERE name='abc'");
while ($row = mysql_fetch_array($sql))
{
echo $row['name'];
}
?>
would it be faster to just use...
<?php
$sql = mysql_fetch_array(mysql_query("SELECT name FROM users WHERE name='abc'"));
echo $sql['name'];
?>
To fetch a single persons name? I always figured you would use the while statement if you wanted to echo the entire table...
<?php
$sql = mysql_query("SELECT name FROM users");
while ($row = mysql_fetch_array($sql))
{
echo $row['name'] . "<br/>";
}
?>