Skip to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MySQL random record

Hallootjes iedereen,

Ik wil op mijn site 5 random records weergeven. Daarvoor heb ik onderstaande codes gebruikt:

MySQL:

$sql = mysql_query("SELECT *
		  FROM afbeeldingen
		  ORDER BY RAND()
		  LIMIT 0,5")
		  or die("Error reading database.");

PHP:

<?php
while($aRecord = mysql_fetch_array($sql)) {
echo "<li><img src='afbeeldingen/".$aRecord['link']."'><img src='afbeeldingen/".$aRecord['link']."' style='max-width: 800px; max-height:180px;' alt='".$aRecord['naam']."' /></a><br /></li>";
}
?>

Het probleem: hij pakt wel 5 verschillende records, alleen hij pakt ze allemaal twee keer.

Weet iemand waar dit aan ligt?

Edited by Kloep

Featured Replies

De query is correct, maar je hebt een image tag gebruikt, terwijl je eigenlijk een link tag wil gebruiken :bier:

<?php
while($aRecord = mysql_fetch_array($sql)) {
echo "<li><a href='afbeeldingen/".$aRecord['link']."'><img src='afbeeldingen/".$aRecord['link']."' style='max-width: 800px; max-height:180px;' alt='".$aRecord['naam']."' /></a><br /></li>";
}
?>

  • Author

Ow, haha lol. Dat is een leuke. :D

Maar de query. Ik dacht dus ook al dat hij gewoon correct was, en dit bleek ook zo te zijn. Er zat gewoon een fout in de javascript dit ik had gedownload. :puh:

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...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.