I came across an old function that I would like to convert to mysqli but I'm stuck at the mysql_result ($result, 0, $colname['i])
part; would it be best to use data/field_seek and if so, what would be the best method?
function friend_data($q, $colname)
{
$result = mysql_query ($q);
if (mysql_num_rows($result) > 0)
{
$colname = explode("|", $colname);
for ($i = 0; $i < count($colname); $i++)
{
global $$colname[$i];
$$colname[$i] = mysql_result ($result, 0, $colname[$i]);
}
}
}
The way this is used right now:
$q = "SELECT first_name,last_name,user_email FROM users WHERE country = '".$country."';
and calling the function friend_data, supplied with the column names:
friend_data ($q, "first_name|last_name|user_email");
the variables ($first_name,$last_name,$user_email)
can now be used in the rest of the code which I would like maintain in that format like below:
function friend_data($q, $colname)
{
$result = $db->query ($q);
if (mysqli_num_rows($result) > 0)
{
$colname = explode("|", $colname);
for ($i = 0; $i < count($colname); $i++)
{
global $$colname[$i];
$$colname[$i] = ... ;
}
}
}
So mysql_result ($result, 0, $colname[$i])
specifically I don't know how to "translate" into working mysqli code.
Any help/tips/pointers on how to proceed would be greatly appreciated!