Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:35:50+00:00 2026-06-14T20:35:50+00:00

I have been trying to learn php and have been getting better day by

  • 0

I have been trying to learn php and have been getting better day by day but still fighting cant wait till everything just falls into place and flow. (With other programming languages it worked that way for me fight for a while then everything just works)

but I am trying to make it return a random account and display all there photos along with data.

Here is my example code

 <?php
$config['db'] = array(
'host' => 'DATA',
'username' => 'WOULD',
'password' => 'GO',
'dbname' => 'HERE'
);

$db = new PDO('mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'], $config['db']['username'], $config['db']['password']);

$query = $db->query("SELECT `content`.`ProfilePic` FROM `content`");

while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$Hello = $row['ProfilePic'];
echo  '<html><img src="http://www.MYDOMAIN.COM/Content/';
echo $Hello;
echo '"></html>';

}
?>

So what this is doing is returning everyones profile pics on one page
Not quite what I want

I have it where in a feild on my mysql data base it has a unique Id for each account I would like it to randomly pic one of those then return all the data for that row

FirstName
LastName
Gender
City
State
FacebookUrl
BirthMonth
BirthDay
BirthYear
AccountNumber - This is the one I want to pull and use to return everything
ProfilePic
ProfilePicCaption

So basically pick a random row and pull all the data instead of displaying all the data for one column

Thank you any and all help is awesome and at least now im using secure code

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:35:52+00:00Added an answer on June 14, 2026 at 8:35 pm

    Use the RAND function

     <?php
    $config['db'] = array(
    'host' => 'DATA',
    'username' => 'WOULD',
    'password' => 'GO',
    'dbname' => 'HERE'
    );
    
    $db = new PDO('mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'], $config['db']['username'], $config['db']['password']);
    
    $query = $db->query("SELECT * FROM `content` ORDER BY RAND() LIMIT 1");
    
    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $Hello = $row['ProfilePic'];
    // and so on, so forth
    echo  '<html><img src="http://www.MYDOMAIN.COM/Content/';
    echo $Hello;
    echo '"></html>';
    
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been trying to learn PHP Repeat Region... i have searched google but
I have been trying to learn how to build jQuery plugins, so I'm still
Ok, this may have been answered, but I'm new and trying to learn, so
I have been trying to learn about classes in PHP and part of my
I have been using PHP for a while, but now I am trying to
I'm very new to PHP so far and have been trying to learn it.
I have been following a tutorial to better understand php's oop, but have come
I am trying to learn more about Javascript, I have been coding with PHP
I have been trying to learn pygame the last day or so, and tried
I have been trying to learn python over the last couple of months and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.