Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-26-2022, 07:31 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,135
Make an 'echo' random in php?

Quote:
$title = $row['Name'];
I'm using the above echo statement to insert data into a page however, it dawned on me that it could be better to pull from a larger selection of data from within that same defined column, is this possible to achieve using a simple echo statement like the one above, just with a little longer statement, that doesnt involve adding SQL queries?

I'm thinking it must be possible using something along the lines of this, maybe just to give an idea of what I'm looking for?

Quote:
$title = $row['Name'] RAND();
Quote:
<?php echo $title; random ?>
Is this possible?

TIA for any assistance.
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-26-2022, 07:57 PM   #2
NoWhErE
Too lazy to set a custom title
 
NoWhErE's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Canada
Posts: 10,331
you'd have to save all the names as an array. I don't know if your data is available in that format, but if it is, all you need to do is $random_title = array_rand($your_array_of_names) and it will output a random result every time.

if your data isn't an array yet, you can create one by adding each name in your database like this

step 1: create an empty array
$array = array();

step 2: go through each name in your db and add it to the array
foreach($row as $name) {
$array[] = $name;
}

now your array is ready to be randomized.
__________________
skype: lordofthecameltoe
NoWhErE is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-26-2022, 08:36 PM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,135
Quote:
Originally Posted by NoWhErE View Post
you'd have to save all the names as an array. I don't know if your data is available in that format, but if it is, all you need to do is $random_title = array_rand($your_array_of_names) and it will output a random result every time.

if your data isn't an array yet, you can create one by adding each name in your database like this

step 1: create an empty array
$array = array();

step 2: go through each name in your db and add it to the array
foreach($row as $name) {
$array[] = $name;
}

now your array is ready to be randomized.
Much appreciated.

Thats what I was afraid of, itll take forever to setup the individual arrays, looks like I need to recode using SQL Queries instead

Thanks!
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-27-2022, 07:28 AM   #4
NoWhErE
Too lazy to set a custom title
 
NoWhErE's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Canada
Posts: 10,331
Quote:
Originally Posted by Publisher Bucks View Post
Much appreciated.

Thats what I was afraid of, itll take forever to setup the individual arrays, looks like I need to recode using SQL Queries instead

Thanks!
It depends. Either way, with SQL queries or with arrays, it should only be a few lines of code at most to get the data you want.
__________________
skype: lordofthecameltoe
NoWhErE is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
statement, echo, $title, data, sql, queries, adding, thinking, involve, idea, rand;, $row[name], tia, assistance, lines, page, dawned, insert, random, php, $row[name];, column, achieve, simple, defined



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.