Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13771

Re: mysqli fetch_assoc() straight to array

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php, comp.databases.mysql
Subject Re: mysqli fetch_assoc() straight to array
Date 2014-05-30 20:52 -0400
Organization A noiseless patient Spider
Message-ID <lmb94h$d3e$1@dont-email.me> (permalink)
References <1d3awnt6q6jee$.1lfurjq9qtvl3.dlg@40tude.net> <9N5iv.502150$l83.240869@fx28.iad> <1jha1xk2xj4hw.1012a4ildu9nd.dlg@40tude.net>

Cross-posted to 2 groups.

Show all headers | View raw


On 5/30/2014 4:54 PM, richard wrote:
> On Fri, 30 May 2014 16:23:32 -0400, Lew Pitcher wrote:
>
>> On Friday 30 May 2014 07:59, in comp.databases.mysql, "richard"
>> <noreply@example.com> wrote:
>>
>>>
>>> Is there a way to make it simpler to just load an array based upon the
>>> results of $row?
>>> Rather than having to assign each individual column one at a time?
>>
>> /This/ is the sort of posting that I was talking about earlier.
>>
>> Richard, this isn't a mysql issue. Mysql does not define how PHP manages
>> array assignments, PHP does.
>>
>>> $array=$row
>>> Versus
>>> $array[col1]=$row[col1]
>>> $array[col2]=$row[col2]
>>>
>>>
>>> while ($y<=69){
>>> while ($n<=40){
>>>
>>> if ($n<10){$n="0".$n;}
>>> $x=$y.$n;
>>> $sql = "SELECT * FROM top20 where songs='$x'";
>>> $result = $mysqli->query($sql);
>>> $row = $result->fetch_assoc();
>>>
>>> echo $n.")  ".$row['songs']."<br>";
>>>
>>> $n++;
>>>
>>> }
>>> $n=1;
>>> $y++;
>>> }
>>
>> Followup set to comp.lang.php
>>
>> FWIW, PHP permits assignment of arrays, so
>>    $row = $result->fetch_assoc();
>>    $array = $row;
>>    echo $n.")  ".$array['songs']."<br>";
>> is legal PHP code.
>
> Thank you sir.
> At least you said "why".
> The others just say it is not an issue in mysql but refused to say why.
> But my question was dealing with a mysql function.
> I just figured there had to be some way of being able to assign the columns
> within the function, but apparently not.
>

Richard, if you had ANY intelligence at all, people wouldn't NEED to 
explain WHY.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-30 16:23 -0400
  Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-30 16:25 -0400
    Re: mysqli fetch_assoc() straight to array richard <noreply@example.com> - 2014-05-30 17:36 -0400
      Re: mysqli fetch_assoc() straight to array Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-31 10:32 -0400
        Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-31 17:21 +0000
  Re: mysqli fetch_assoc() straight to array richard <noreply@example.com> - 2014-05-30 16:54 -0400
    Re: mysqli fetch_assoc() straight to array Jürgen Exner <jurgenex@hotmail.com> - 2014-05-30 14:08 -0700
    Re: mysqli fetch_assoc() straight to array Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 23:11 +0200
      Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-30 20:53 -0400
        Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-31 17:26 +0000
          Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-31 15:08 -0400
            Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-01 10:35 +0000
    Re: mysqli fetch_assoc() straight to array Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-30 23:27 +0000
    Re: mysqli fetch_assoc() straight to array Jerry Stuckle <jstucklex@attglobal.net> - 2014-05-30 20:52 -0400

csiph-web