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 8313295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:26:42+00:00 2026-06-08T20:26:42+00:00

I can loop through a table, grab the rows and echo them out within

  • 0

I can loop through a table, grab the rows and echo them out within the loop. How do I use this data outside the loop?

$query=("SELECT * FROM poplinks");
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
    $popid = $row['popid'];
    $popname = $row['popname'];
    $popurl = $row['popurl'];

echo $popurl;
}

The echo statement above echos the 10 popurl values in the db, but if I try and echo $popurl outside of the loop I only get the last value. I guess I want an array of all the values stored in a variable.

Update:
The data is going into something like the below HTML: (note “echo $popurl” on line 3. The idea is to get the Twitter Bootstrap Typeahead function to read from a database. At the moment by appending [] to each of the variables inside the loop, I can get the below code working if I include the index e.g. but I can’t get the entire row in there.

<div class="well">
<form action="" method="post" onsubmit="proceed();">
<input type="text" class="span3" name="content" value="<?php echo $liLink->sContent; ?>" data-provide="typeahead" data-items="4" data-source='["Alabama", "<?php echo $popurl ?>" ,"Alaska","Arizona","Arkansas"]'/>
<input type="submit" name="submit" value="save" />
</form>

  • 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-08T20:26:44+00:00Added an answer on June 8, 2026 at 8:26 pm

    Try this

    $query=("SELECT * FROM poplinks");
    $result = mysql_query($query);
    
    $myArray='';
    while($row = mysql_fetch_array($result)){
        $popid = $row['popid'];
        $popname = $row['popname'];
        $popurl = $row['popurl'];
    
    $myArray[] = $popurl;
    }
    
    echo "<pre>";
    print_r($myArray);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I loop through this json data without referring to the data items
I know I can loop through a list of strings like this: list<string>::iterator Iterator;
How can I use a batch file to loop through non-integer values? I'm trying
I want to know that How can I walk through this loop ? this
How can I loop through table and row that have an attribute id or
I have a while loop that goes through a table and I echo the
I need to be able to loop through an HTML table and output data.
I have the following xml that stores table definations. How can I loop through
I can loop through all of the rows in a php script and do
I use Mechanize to loop through a table, which is paginated. I have a

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.