Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to make object .

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to make object .

Postby phpdeveloper13 » Sun Nov 10, 2013 10:48 pm

This is my code
Code: Select all
$video = "SELECT * FROM `video123`;
$vid = $mysqli->query($video) or die($mysqli->error.__LINE__);
    if($vid->num_rows!=0)
    {
             while($row = $vid->fetch_assoc())
        {
                               $row['id'];
                               $row['yt_title'];
                               $row['description'];
        }
     }



I want its response to be like this.



Code: Select all
Array
(
   
    [0] =>
        (
           [$row['id']]=>124
           [$row['yt_title'];]=>vi1
            [$row['description']]=>dasd
        )
 [1] =>
        (
           [$row['id']]=>127
           [$row['yt_title'];]=>sda
            [$row['description']]=>sads
        )



thanks
phpdeveloper13
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Nov 10, 2013 10:45 pm

Re: How to make object .

Postby MarioParty » Sat Dec 28, 2013 3:26 pm

I'm not really sure what you mean? You already have everything that you require.

Code: Select all

$video 
= "SELECT * FROM `video123`;
$vid $mysqli->query($video) or die($mysqli->error.__LINE__);
    if(
$vid->num_rows!=0)
    {
             
$video_array = array();
             while(
$row $vid->fetch_assoc()) 
             {
                
$video_array[] = $row;
             }
     }

var_dump(
$video_array);
MarioParty
New php-forum User
New php-forum User
 
Posts: 42
Joined: Tue Aug 02, 2011 2:52 am


Return to PHP coding => General

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron