Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
http://img293.imageshack.us/img293/857/tablez.jpg
Here is a picture of the 2 tables.
The mybb_users table is the table that has the users that signed up for the forum.
The mybb_userfields is the table that contain custom profile field data that they are able to customize & change in their profile.
Now, all I want to do is display all users in rows with the custom profile field data that they provided in their profile(which is in the mybb_userfields table)
How can I display these fields correctly together?
For instance, p0gz is a male,lives in AZ,he owns a 360,does not know his bandwidth & Flip Side Phoenix is his team.
How can it just be like "p0gz-male-az-360-dont know-flipside phoenix" in a row~???
This looks for me like an ordinary LEFT JOIN
SELECT * FROM mybb_users
LEFT JOIN mybb_userfields
ON (mybb_users.uid = mybb_userfields.ufid)
WHERE username = 'p0gz'
This should display every row of the user p0gz
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have advertise table and it has ids
Advertise
-----------------------------------
ID Title Code Position
-----------------------------------
1 Ad 1 Somecode Left
2 Ad 2 Somecode Right
3 Ad 3 Somecode Bottom
-----------------------------------
My Display page has different functions so i cannot use while loop to break my other codes and then continue again. I even dont want to add three different queries to fetch each id. I have 3 fixed positions bottom, left and right so i want to add specific id to its specific div.
It is unclear to me what you are asking. But to give you a general idea as to how to pull data from a database, you can some of the following code:
$query = "SELECT * FROM table_name WHERE Position = 'Left'";
$query = "SELECT ID FROM table_name WHERE Code = 'Somecode'";
$query = "SELECT Position FROM table_name WHERE ID = 3";
Please feel free to ask any follow up questions.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hi guys I have Google to get answer for the above question but I got the answer for displaying the plain bar graph one but not stacked bar graph.
My problem is I have to display the stacked bar graph based on the number of count of different categories for example the number of login to the site, reset password, chats etc.And I have to use plugin for displaying of graph.
I would request you guys to please suggest me some thing on this.As I'm new to php.
Thanks in advance guys
I think I understand the question (a good one)
SELECT category, COUNT(category)
FROM users
GROUP BY category
ORDER BY category
This displays the total number of hits for each category. In javascript I use AJAX call to execute the php - mysql, then return the array of counts back to the javascript to display the stack graph.
I executed this code on my system, just substitute "where user_id = 36" for "where date = 31032015" (whatever date format), and change the table "users" to your table name.
$template2=mysql_query("SELECT category, COUNT(category) FROM users where user_id = 36
GROUP BY category ORDER BY category ");
while($template=mysql_fetch_array($template2)){
echo "<tr><td>{$template['COUNT(category)']} {$template['category']}</td></tr>";
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm hoping one of you more experienced programmers might be able to shed some light on this situation:
My site allows users to create a profile and enter in their favorite musicians, all of which reside in a pre-existing database of musicians.
Based on the artists they select, I want to display to them other users who have selected the same artists.
Can anyone offer suggestions on how this could be effectively accomplished?
I'm using SQL and PHP for the back end.
You would need to create a cross-reference table between users and musicians that defines the 'likes' relationship. At a minimum it would just need to contain the user id and musician id.
CREATE TABLE user_likes_musician (
user_id INT NOT NULL,
musician_id INT NOT NULL,
PRIMARY KEY(user_id, musician_id)
);
To find users who liked a particular musician you can just join the likes table with the users table:
SELECT * FROM users
JOIN user_likes_musician
ON (users.ID = user_likes_musician.user_id
AND user_likes_musician.user_id <> [current user id]
AND user_likes_musician.musician_id = [musicians id]);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm very new to all this...and for a project work in my college I have decided to make an online shopping website.
I am stuck at the sign up part.
I wanted the users to have a separated table for themselves that allow them to store the products that they have added in their cart so that they can keep adding more products later as well.
But as I read in other questions in all your links, creating a table per user seems to be a very bad idea.
but otherwise how can I do it? Please help.
Let me explain in detail.
I guess you have already created table for user and product. if not then you need to create table for user and product with unique value of user_id and product_id respectively.
Now create user_shopping cart table with following fields
user_id
product_id
product_qty
You can update user_shopping as per you need.
Make one table that contains the columns user_id and product_id.
That way you can associate products with users without needing a table for each user.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hi i am working on site where users login to read articles, every articles is based in a category. so i want to display on the 'user home page' the category and article the last have visited/read. This counts for multiple category, so it neets to display "category 'a' read 12 of 20 articles 'click here to continue reading' " If someone can help me or send me in the right direction, any help / info is very much appreciated. Thank you
There's no special utility that can do something like that for you, if that's what you're thinking. What you will need to do is create a table in MySQL that stores a list of articles read by your users. Maybe a table with just user_id and article_id, together making up the primary key. INSERT IGNORE when a user visits an article, and when you want to get how many articles have been read, you can SELECT COUNT(*) FROM table WHERE user_id = ?
SELECT COUNT(*) FROM table WHERE user_id = ? AND article_id IN (SELECT id FROM articles WHERE category_id = ?)
The query above would let you get the number of articles that the specified user has viewed within the specified category, assuming you have it set up like this.
You also mentioned that you want to be able to select the most recent article or category the user has read. To do that, you can add a timestamp field to the new table you created. Another way is to add an auto_increment field and grab the biggest one.
Just an idea. You can create an extra table , lets call it user_read and store which user read which article.
Table user_read
user_id
article_id
I assume you know which article belongs to each category, therefor you can count how many articles in each category the user has read.