Skip to main content
edited body
Source Link
marc_s
  • 759.6k
  • 185
  • 1.4k
  • 1.5k

First you don't want to loop though quiriesqueries. You want to loop through records which query will return.

Second you could do that, this way:

$conn = db_connect();

$query = mysql_query("SELECT info, username, time FROM newsfeed ORDER BY time DESC LIMIT 10");

while(($row = mysql_fetch_assoc($query)) != NULL) {

    echo "<p>User {$row['username']} just registered {$minutes} min ago</p><br />";
    
}

NB! Assuming, that this db_connect() makes a mysql connection.

First you don't want to loop though quiries. You want to loop through records which query will return.

Second you could do that, this way:

$conn = db_connect();

$query = mysql_query("SELECT info, username, time FROM newsfeed ORDER BY time DESC LIMIT 10");

while(($row = mysql_fetch_assoc($query)) != NULL) {

    echo "<p>User {$row['username']} just registered {$minutes} min ago</p><br />";
    
}

NB! Assuming, that this db_connect() makes a mysql connection.

First you don't want to loop though queries. You want to loop through records which query will return.

Second you could do that, this way:

$conn = db_connect();

$query = mysql_query("SELECT info, username, time FROM newsfeed ORDER BY time DESC LIMIT 10");

while(($row = mysql_fetch_assoc($query)) != NULL) {

    echo "<p>User {$row['username']} just registered {$minutes} min ago</p><br />";
    
}

NB! Assuming, that this db_connect() makes a mysql connection.

Source Link
Eugene
  • 4.4k
  • 9
  • 57
  • 79

First you don't want to loop though quiries. You want to loop through records which query will return.

Second you could do that, this way:

$conn = db_connect();

$query = mysql_query("SELECT info, username, time FROM newsfeed ORDER BY time DESC LIMIT 10");

while(($row = mysql_fetch_assoc($query)) != NULL) {

    echo "<p>User {$row['username']} just registered {$minutes} min ago</p><br />";
    
}

NB! Assuming, that this db_connect() makes a mysql connection.