top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to execute an sql query and how to fetch its result in PHP?

–1 vote
449 views
How to execute an sql query and how to fetch its result in PHP?
posted Mar 13, 2017 by Kavyashree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

This is how we achieve -

for ($attempt=0; $attempt<100; $attempt++) {
      $result=mysql_query($query, $db);

      if (($result===false) && (mysql_errno($db)==1213))
          usleep(10000); // dead with InnoDB deadlock errors by waiting 0.01s then retrying
      else
          break;
}

Now we got the result in $result and we can try the following options -

while ($row=mysql_fetch_row($result)) {
  ...
}

while ($assoc=mysql_fetch_assoc($result)) {
   ...
}
answer Mar 13, 2017 by Salil Agrawal
...