0
$result=mysqli_query($con, "SELECT * FROM `Products` WHERE `Reference`='$Reference'");

When I execute this query, I can fetch the query results and store in a 2-dimensional array using the mysqli_fetch_assoc() function. But retrieving a specific value from a specific row of the result can sometime be confusing especially if the fetching, storing and retrieving are done inside a loop nested inside another loop nested in a loop - where there are many loop counters.

It was very convenient using the old way:

$result=mysql_query("SELECT * FROM `Products` WHERE `Reference`='$Reference'");

That way I could simply retrieve anything inside any number of nested loops using the loop counter, for example:

$Cost=mysql_result($result, $counter, "Cost");

What is the new equivalent of the old mysql_result function, so that I can directly retrieve the results using the counter and field exactly like the deprecated way, without first having to fetch, store and eventually retrieve?

More and more I am beginning to feel as if the MYSQL improved, it is in fact the MYSQL inconvenienced.

  • http://php.net/manual/en/function.mysql-result.php there are few helpful links in there how to do it the "old way" – Siim Kallari Apr 10 '15 at 09:09
  • Also, be sure to used prepared statements: http://stackoverflow.com/a/60496/3455727 –  Apr 10 '15 at 10:30

0 Answers0