FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Re: mysqli fetch_assoc() straight to array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: mysqli fetch_assoc() straight to array [message #186015 is a reply to message #186010] Sat, 31 May 2014 00:52 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
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(at)example(dot)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(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: mysqli fetch_assoc() straight to array (-> comp.lang.php)
Next Topic: ArrayAccess interface, Traversable interface and foreach
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 09:20:01 GMT 2024

Total time taken to generate the page: 0.06315 seconds