Welcome Guest, Not a member yet? Register   Sign In
return data from different table sql to html
#1

[eluser]kolxoznik1[/eluser]
My tables:

users

id
username

images

id
user_id
image
description
date <--- uplaod date

user_favorites

id
user_id <---user id who like image
image_id <---id of liked image
date <---date when image was clicked "liked"


My htmp page have it's own structure for favourites and images so I need hrlp | advice how to make sql out to this html . I have made sql and it return :

Code:
[everything_list] => Array
        (
            [0] => Array
                (
                    [user] => 8888
                    [user_image] => http://127.0.0.1/auth_system_1/upload_images/24/24_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                    [uploaded_image] => http://127.0.0.1/auth_system_1/upload_images/224/224_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                    [image_id] => 4
                    [text] =>
                    [image_date] => 1328577934
                    [comments] => 0
                    [favorite_id] => 5
                    [favorited_image] => http://127.0.0.1/auth_system_1/upload_images/100/100_flw3utn9igiqh7dtt2o61ydf8_174.jpeg
                    [favorite_user] => 6666
                    [favorite_user_image] => http://127.0.0.1/auth_system_1/upload_images/24/24_flw3utn9igiqh7dtt2o61ydf8_174.jpeg
                )

            [1] => Array
                (
                    [user] => 8888
                    [user_image] => http://127.0.0.1/auth_system_1/upload_images/24/24_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                    [uploaded_image] => http://127.0.0.1/auth_system_1/upload_images/224/224_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                    [image_id] => 4
                    [text] =>
                    [image_date] => 1328577934
                    [comments] => 0
                    [favorite_id] => 2
                    [favorited_image] => http://127.0.0.1/auth_system_1/upload_images/100/100_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                    [favorite_user] => 8888
                    [favorite_user_image] => http://127.0.0.1/auth_system_1/upload_images/24/24_0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                )

        )

I have 1 image and 2 favourites so it return 2 favourites and 1 image (1 image is duplicating in array) so when I try to foreach data it show 2 images instead of 1 ? What to do ?

my sql query :

[Image: e3ed2ec4065b.jpg]

sorry for not code, codeigniter forum do not allow me to add such big sql ( Sorry don't know why

#2

[eluser]InsiteFX[/eluser]
You need to unset the image in the second array to delete it!
#3

[eluser]kolxoznik1[/eluser]
InsiteFX how to do it? you mean I need foreach and unset before sending to view? or I need to do it in sql?

Maybe you can give a small tutorial, example ?

for example [favorited_image] is different but [uploaded_image] is the same so I need to delete (unset) some array




Theme © iAndrew 2016 - Forum software by © MyBB