mam bazę danych w których jedna z tabel prezentuje się następująco
CREATE TABLE `14_tutorials` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Title` text NOT NULL, `Date` date NOT NULL, `Desc` text NOT NULL, `ShortDesc` text NOT NULL, `Graphic` text NOT NULL, `Category` int(11) NOT NULL, `Level` int(11) NOT NULL, `Price` float NOT NULL, `Currency` text NOT NULL, `TotalEarned` float NOT NULL, `AllowComments` int(11) NOT NULL, `AllowHands` int(11) NOT NULL, `AllowSharing` int(11) NOT NULL, `AllowLiking` int(11) NOT NULL, `Active` int(11) NOT NULL, `AllowPayPal` int(11) NOT NULL, `Lang` text NOT NULL, `isTEXT` text NOT NULL, `isAUDIO` text NOT NULL, `isVID` text NOT NULL, `TotalDownloads` int(11) NOT NULL DEFAULT '0', `TotalViewed` int(11) NOT NULL DEFAULT '0', `TotalHands` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) )
Takich tabel jest kilka. Chodzi o to żeby pobrać je w jedno zapytanie z którego można przestortować tak aby uzyskać 10 rekordów, dla których `TotalHands` jest największe.
Próbowałem zrobić to w ten sposób, ale mi nie wyszło. Może pomożecie.

function getBest($excludeMe){ $link = mysqli_connect(); //tu jest ok, po prostu nie pokazuje wam danych $counter = 0; $query = ""; if($excludeMe){ $query = "SELECT * FROM `users` WHERE `ID`<>".$_SESSION['user'][0]; }else{ $query = "SELECT * FROM `users`"; } $run = mysqli_query($link, $query); if($run){ while($użytkownik = mysqli_fetch_row($run)){ $query = "SELECT `ID`,`Title`,`TotalHands` FROM `$użytkownik[0]_tutorials`"; $run1 = mysqli_query($link,$query); while($kurs = mysqli_fetch_row($run1)){ if($counter>0){ if($kurs[2]>$all[$lastID]){ $all[$counter][0] = $kurs[0]; $all[$counter][1] = $użytkownik[0]; $all[$counter][2] = $kurs[1]; $all[$counter][3] = $kurs[2]; $counter++; } }else{ $all[$counter][0] = $kurs[0]; $all[$counter][1] = $użytkownik[0]; $all[$counter][2] = $kurs[1]; $all[$counter][3] = $kurs[2]; $counter++; } } } return $all; }else{ return 1; } }