How do i show platform with its all categories from database using php mysql?

Hello,
i have some problem that i don’t understand how to solve it. Please see the image target image to getting understand what i wants to do.

This image taken from ebay website.

In this image you will see the block of images and at the bottom you will see the categories. i have a database in which i have a category table where i have these three categories. and another table plateform where i define all plateform with their categories. like i have PS4 with category(1,2,3) (1 = console, 2 = accessories, 3 = games) but some have only 2 categories. so this is the design of my plateform table. Okay So, i wants to use plateform table to display blocks with categories like you see in image but i am new to mysql i don’t understand how it works. Kindly Help Me. Solve this problem.I shall be really thankful to you.

So from what you are asking, you haven’t done any coding yourself?

What i have done is here.

	 $sql = "SELECT DISTINCT * FROM plateform WHERE PlateformName 
	 IN ('Sony PlayStation 4','Sony PlayStation 3','Microsoft Xbox 360','Microsoft Xbox One','Nintendo Wii','Nintendo Wii U')
	 ;";
	
	$query = mysqli_query($connect,$sql);
	$numrow = mysqli_num_rows($query);
	
	  <?php
				while($rows = mysqli_fetch_assoc($query))
				{
			?>
					<section class="platform-product">
						<figure>
							<img src="image from database" >
							<figcaption>
								<a href="" title="image name Consoles">this plateform Console</a> |
								<a href="" title="image name accessories">this plateform Accessories</a> |
								<a href="" title="image name games">this plateform Games</a>
							</figcaption>
						</figure>
					</section>
			<?php 
				}
			?>

This is what i have done i don’t understand how it works.

The IN operator reduces the need to use multiple OR operators in a query. You are basically specifying the PlateformName in the IN operator to grab the specific rows.

Yes i wants only number of plateform to display, Please give me a complete solution of how to do i have a presentation thursday and today is wednesday. and this is my last step of my website please please please… help meeeeeeeeeeeeeee. i try anything to seperate categories id to make thing like you see in picture but nothing get. i shall be very thank ful if you help me. i have a less time remaining to my presentation and i am completely sucked please help me solve this problem. please please please.

I’m not sure that’s how things work on any forums. I’m happy to help you solve the problem if I can, but not to just code it for you.

3 Likes

The asterisk in the query loosely translates to “all fields”

SELECT DISTINCT * 
FROM plateform 
WHERE PlateformName 
IN ('Sony PlayStation 4'
    ,'Sony PlayStation 3'
    ,'Microsoft Xbox 360'
    ,'Microsoft Xbox One'
    ,'Nintendo Wii'
    ,'Nintendo Wii U')

If you don’t want all the fields, change that.

I don’t know the field identifier that holds the “number”, or maybe you want COUNT? So it would be more like

SELECT DISTINCT `number-field-name-here` 

or maybe

SELECT COUNT( DISTINCT `number-field-name-here` )

okay i do it but how i get their categories id (console,accessories,games) like you see in image.any solution please getting specific number of plateform from database is already done it i’m asking how to get every single platform’s category so that i show it please see image. please please please…

Thanks for helping me, you can do according to you or give me an idea how i sepearate or get every single plateform’s categories(console,accessories,games).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.