top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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

–1 vote
120 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...