Jump to content

select to array


raduenea

Recommended Posts

In witch conditions you need to transfer the data from a select in array and after that to show from array in content of the page ?

 

I have no idea what you are asking and i don't think anyone else will, try rewording your question.

Link to comment
Share on other sites

I have two tables : one with users and another one with the number of images that they have uploaded.

I mentioned that some images have the option to show or not in the site.

 

I want to show all the users with a picture on every user (take from table 2 if the picture exist), and to show the number of images that he uploaded.

If the user don't have any images uploaded he must not appear.

 

That's why I asked if it's necessary to show all this from an array for a better organization.

 

Please tell me know how can I do that.

Thks

Link to comment
Share on other sites

If you do have `user_id` in your `images` table, you can easily get around this by query:

SELECT `images`.`img`, COUNT(`images`.`id`) AS count_img, `users`.*
FROM `images`
LEFT JOIN `users` ON `images`.`user_id` = `users`.`id`
GROUP BY `images`.`user_id`

 

In this way, users who didn't upload any image wouldn't even be included in the return results. Not sure if this is what you're expecting.

Link to comment
Share on other sites

The structure of this two tables is:

user table:

- id

- firstname

- lastname

- company

- address

- phone

- email

 

images table:

- id

- user_id

- picture_title

- year

- visible

- picture_path

 

I must notice that the user can hide the pictures. So he can have picture in images table but hide (visible column).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.