Webmaster Forum

Webmaster Forum (http://www.v7n.com/forums/index.php)
-   Coding Forum (http://www.v7n.com/forums/forumdisplay.php?f=16)
-   -   Best practice row[ x ] to variable (http://www.v7n.com/forums/showthread.php?t=429416)

ScriptMan 08-11-2018 06:12 AM

Best practice row[ x ] to variable
There is nothing like being timely and my time is about up to convert mysql queries to mysqli queries. :mrgreen:

The second one took no where near as long as the first one.

The third one caused me some problems and in the process of getting that one working I discovered that this code
PHP Code:

 echo $row[0],$row[1],$row[2] . "<br />"

would work when displaying a query result that only contained data from 3 columns while using the old mysql format
PHP Code:

echo $row['id'],$row['title'],$row['rate'] . "<br />"

throws an Undefined index: error.

Converting the $row[x] to a named variable as the rows are processed also works and may be the more simple approach as I format the data later in the script. I may answer my own question.

My mind says that conversion makes it easier to follow a year from now but the $row[x] method sure is faster.

What say you? Is there a proper practice?

All times are GMT -7. The time now is 01:42 PM.