Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

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.

PHP Testimonials system

Featured Replies

im currently in the middle of designing a website for a client and basically we have a testimonials page which i will uses simple html to document them, but we also have a right side bar on each page which currently is not doing anything so i thought it would be a good idea to write a little php script which would generate a random testimonial and echo it out into a <div>. It works fine, but each div displays the same testimonial, and obviously i want them to be completely unique.

 

Here is the code im using

im callig this from a seperate file

<?php
     $randRotate = rand(0,4);

     $text[0] = 'Your text 1';
     $text[1] = 'Your text 2';
     $text[2] = 'Your text 3';
     $text[3] = 'Your text 4';
     $text[4] = 'Your text 5';
?> 

 

And then in each separate div i have

<?php
echo($text[$randRotate]);
?> 

 

im not brillian with php, but i understand the concept of it.

 

thanks for any help you can give

  • Author

thats worked, i am now in theory getting a different random value, but i am still getting duplicate random entries.

 

Is there a way i can validate it to keep randomizing the selection until the returned result is totally unique?

 

this will be awful syntax probably but something like this....

 

<?php
if ($text = = $text [$rand_keys]);
?>

 

thanks

  • Author

hmm, ive tried array_unique() but cant seem to get it to work :(

 

php hurts my brain....

Create an account or sign in to comment

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.