Welcome to www.HAS.lv - programmējam HTML.

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
nusun

php while

Šis ir mans kods

<?php
	$sql = mysqli_query($conn, "SELECT ` FROM race");
	while($row = mysqli_fetch_array($sql)){

		echo $row["year"];
	}
?>

Šis ir rezultāts

original.png

 

Kā panākt, lai viņs izvelk visu šo informāciju, bet uz ekrāna tabulā izvada tikai 1x 1974.
Jo man vajag informāciju kas nāk kopā ar šo gadu, teiksim sacensību kopskaitu tajā gadā.

race DB

id year month day track
id 1974  2       4      2

Vai arī aizmirstam visu no paša sākuma un tupa taisīt DB ar gadiem vai kaut kādu +1 joku?
Kā labāk?

0

Share this post


Link to post
Share on other sites
SELECT year, SUM(race_count) from race GROUP BY year

have fun

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0