What is the use of the MYSQL_BOTH in the code?

Asked By 0 points N/A Posted on -
qa-featured

For example from this code if($count>0){

if($count>0){
while($row=mysql_fetch_array($result,MYSQL_BOTH)){
$username=$row['username']; $user_id=$row['user_id'];
$query5 ="UPDATE message SET status='read' WHERE user='$userdata'";
$result5=mysql_query($query5,$link) or die("Error". mysql_error());
 
$query1="select * from message Where user='$user_id' ORDER BY date DESC, time DESC";
$result1=mysql_query($query1,$link) or die ("Error". mysql_error());
$count1=mysql_num_rows($result1);
SHARE
Answered By 35 points N/A #177669

What is the use of the MYSQL_BOTH in the code?

qa-featured

Hi Chillz18,

When mysql_fetch_array() is used, it fetches the result row as an associative or numeric array.You can choose to fetch both associative and numeric array by using the MYSQL_BOTH type. To fetch only the associative array, you can use MYSQL_ASSOC.To fetch only the numeric array you can use MYSQL_NUM.

Here using MYSQL_BOTH you can access both the fields in the column, the username and user id.

Regards,

Related Questions