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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:05:23+00:00 2026-05-26T02:05:23+00:00

I have this code to pull data from the database and insert the data

  • 0

I have this code to pull data from the database and insert the data into one of 4 columns,

I have spent a whole day searching and just cant seem to find out how to do it..

Ideally, I want to select all from database and then where the fetch array has a column id of 1 – echo that then the sama for the next column etc..

<?php


            echo '<div class="column grid_3 clearfix" id="column0" >';
            echo '&nbsp;';
            $user_sites_0=mysqli_query($connection, "SELECT * FROM user_sites WHERE column_id='0' ORDER BY sort_no");

            if(!$user_sites_0) {
                echo 'No sites added, please <a class="addsite" href="#">add one now</a>';
            }
            else {

                while($user_site_0=mysqli_fetch_array($user_sites_0))
                {
                    $id = stripslashes($user_site_0['id']);
                    $site_name = stripslashes($user_site_0['site_name']);
                    $site_address = stripslashes($user_site_0['site_address']);
                    $site_desc = stripslashes($user_site_0['site_desc']);
                    $site_category = stripslashes($user_site_0['site_category']);
                    $getImage = 'http://immediatenet.com/t/s?Size=1024x768&URL='.$site_address;
                    echo '<div class="dragbox" id="item'.$id.'">';
                    echo '<h2 class="h2handle">'.$site_name.' <span class="close"><a href="#" id="'.$id.'" class="delete_button"><img src="assets/img/closepanel.png"></a></span></h2>';
                    echo '<div class="dragbox-content" ';
                    if($user_site_0['collapsed']==1)
                        echo 'style="display:none;" ';
                    echo '>';
                    echo '<p><a class="sitelink" href="' . $site_address . '" title="'.$site_name.'"><img src="'.$getImage.'" alt="'.$site_name.'" title="'.$site_name.'"/></a>';
                    echo '<p>' . $site_category . '</p>';
                    echo '<p>' . $site_address . '</p>';
                    echo '<p>' . $site_desc . '</p>';
                    echo'   </div>
                    </div>';

                }

            }
            echo '</div>';



    ?>
    <?php


            echo '<div class="column grid_3 clearfix" id="column1" >';
            echo '&nbsp;';
            $user_sites_1=mysqli_query($connection, "SELECT * FROM user_sites WHERE column_id='1' ORDER BY sort_no");

            if(!$user_sites_1) {
                echo '';
            }
            else {

                while($user_site_1=mysqli_fetch_array($user_sites_1))
                {
                    $id = stripslashes($user_site_1['id']);
                    $site_name = stripslashes($user_site_1['site_name']);
                    $site_address = stripslashes($user_site_1['site_address']);
                    $site_desc = stripslashes($user_site_1['site_desc']);
                    $site_category = stripslashes($user_site_1['site_category']);
                    $getImage = 'http://immediatenet.com/t/s?Size=1024x768&URL='.$site_address;

                    echo '<div class="dragbox" id="item'.$id.'">';
                    echo '<h2 class="h2handle">'.$site_name.' <span class="close"><a href="#" id="'.$id.'" class="delete_button"><img src="assets/img/closepanel.png"></a></span></h2>';
                    echo '<div class="dragbox-content" ';
                    if($user_site_1['collapsed']==1)
                        echo 'style="display:none;" ';
                    echo '>';
                    echo '<p><a class="sitelink" href="' . $site_address . '" title="'.$site_name.'"><img src="'.$getImage.'" alt="'.$site_name.'" title="'.$site_name.'"/></a>';
                    echo '<p>' . $site_category . '</p>';
                    echo '<p>' . $site_address . '</p>';
                    echo '<p>' . $site_desc . '</p>';
                    echo'   </div>
                    </div>';

                }
            }
            echo '</div>';



    ?>
    <?php


            echo '<div class="column grid_3 clearfix" id="column2">';
            echo '&nbsp;';
            $user_sites_2=mysqli_query($connection, "SELECT * FROM user_sites WHERE column_id='2' ORDER BY sort_no");

            if(!$user_sites_2) {
                echo '';
            }
            else {

                while($user_site_2=mysqli_fetch_array($user_sites_2))
                {
                    $id = stripslashes($user_site_2['id']);
                    $site_name = stripslashes($user_site_2['site_name']);
                    $site_address = stripslashes($user_site_2['site_address']);
                    $site_desc = stripslashes($user_site_2['site_desc']);
                    $site_category = stripslashes($user_site_2['site_category']);
                    $getImage = 'http://immediatenet.com/t/s?Size=1024x768&URL='.$site_address;

                    echo '<div class="dragbox" id="item'.$id.'">';
                    echo '<h2 class="h2handle">'.$site_name.' <span class="close"><a href="#" id="'.$id.'" class="delete_button"><img src="assets/img/closepanel.png"></a></span></h2>';
                    echo '<div class="dragbox-content" ';
                    if($user_site_2['collapsed']==1)
                        echo 'style="display:none;" ';
                    echo '>';
                    echo '<p><a class="sitelink" href="' . $site_address . '" title="'.$site_name.'"><img src="'.$getImage.'" alt="'.$site_name.'" title="'.$site_name.'"/></a>';
                    echo '<p>' . $site_category . '</p>';
                    echo '<p>' . $site_address . '</p>';
                    echo '<p>' . $site_desc . '</p>';
                    echo'   </div>
                    </div>';
                }
            }
            echo '</div>';              

    ?>
    <?php


            echo '<div class="column grid_3 clearfix" id="column3">';
            echo '&nbsp;';
            $user_sites_3=mysqli_query($connection, "SELECT * FROM user_sites WHERE column_id='3' ORDER BY sort_no");

            while($user_site_3=mysqli_fetch_array($user_sites_3))
            {
                $id = stripslashes($user_site_3['id']);
                $site_name = stripslashes($user_site_3['site_name']);
                $site_address = stripslashes($user_site_3['site_address']);
                $site_desc = stripslashes($user_site_3['site_desc']);
                $site_category = stripslashes($user_site_3['site_category']);
                $getImage = 'http://immediatenet.com/t/s?Size=1024x768&URL='.$site_address;

                echo '<div class="dragbox" id="item'.$id.'">';
                echo '<h2 class="h2handle">'.$site_name.' <span class="close"><a href="#" id="'.$id.'" class="delete_button"><img src="assets/img/closepanel.png"></a></span></h2>';
                echo '<div class="dragbox-content" ';
                if($user_site_3['collapsed']==1)
                    echo 'style="display:none;" ';
                echo '>';
                echo '<p><a class="sitelink" href="' . $site_address . '" title="'.$site_name.'"><img src="'.$getImage.'" alt="'.$site_name.'" title="'.$site_name.'"/></a>';
                echo '<p>' . $site_category . '</p>';
                echo '<p>' . $site_address . '</p>';
                echo '<p>' . $site_desc . '</p>';
                echo'   </div>
                </div>';
            }
            echo '</div>';              

    ?>

The code looks a right state.. Could I do it better?

  • 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-05-26T02:05:23+00:00Added an answer on May 26, 2026 at 2:05 am

    Use for and change the code, some code :

    <?php
    
    for ($i=0; $i<4; $i++)
    {
      echo '<div class="column grid_3 clearfix" id="column'.$i.'" >';
      echo '&nbsp;';
      $user_sites=mysqli_query($connection, "SELECT * FROM user_sites WHERE column_id='".$i."' ORDER BY sort_no");
      if(!$user_sites) {
        echo 'No sites added, please <a class="addsite" href="#">add one now</a>';
      }
      else
      {
        while($user_site=mysqli_fetch_array($user_sites))
        {
           ... // Do it yourself 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pull data from a table I have imported into my
I have an SSIS package set up to pull data from an Oracle database
I have this code that performs an ajax call and loads the results into
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have built an iPhone app that needs to pull data from a server.
Currently we have a table with a bunch of data from a database which
hey guys, i manage to get this script working to pull data from my
I am writing code that pulls data from database tables and writes them to
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:

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.