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

  • Home
  • SEARCH
  • 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 5963751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:18:34+00:00 2026-05-22T19:18:34+00:00

<?php $objConnect = mysql_connect(localhost,,root) or die(mysql_error()); $objDB = mysql_select_db(mydb); $pic2 = SELECT * FROM

  • 0
<?php
$objConnect = mysql_connect("localhost","","root") or die(mysql_error());
$objDB = mysql_select_db("mydb");
$pic2 = "SELECT * FROM thumbs";
if (!isset($_GET['Page']))  $_GET['Page']='0';
$pic1 = mysql_query($pic2);
$Num_Rows = mysql_num_rows($pic1);
$Per_Page = 16;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
    $Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
    $Num_Pages =1;}
    else if(($Num_Rows % $Per_Page)==0)
    {
        $Num_Pages =($Num_Rows/$Per_Page) ;
    }
    else
    {
        $Num_Pages =($Num_Rows/$Per_Page)+1;
        $Num_Pages = (int)$Num_Pages;}
        $pic2 .=" order  by thumbnailID ASC LIMIT $Page_Start , $Per_Page";
        $pic1  = mysql_query($pic2);
        $cell = 0;
        $link1 = "SELECT * FROM thumbs";
        $result_link1 = mysql_query($link1);
        $link = mysql_fetch_array($result_link1);
        $alt1 = "SELECT * FROM thumbs";
        $alt = mysql_fetch_array(mysql_query($alt1));
        $height1 = "SELECT * FROM thumbs";
        $height = mysql_fetch_array(mysql_query($height1));
        $width1 = "SELECT * FROM thumbs";
        $width = mysql_fetch_array(mysql_query($width1));
        $time1 = "SELECT * FROM thumbs";
        $time = mysql_fetch_array(mysql_query($time1));
        $folder1 = "SELECT * FROM thumbs";
        $folder = mysql_fetch_array(mysql_query($folder1));
        $filed1 = "SELECT * FROM thumbs";
        $filed = mysql_fetch_array(mysql_query($filed1));
        echo '
         <div id="tablediv">
         <table border="0" cellpadding="17" cellspacing="0" class="table">
         <tr>';

        while($pic = mysql_fetch_array($pic1))
        {
            if($cell % 4 == 0)
            {
                echo '</tr><tr>';
            }
        {
        echo'
         <td>
          <a href="/' . $link["link"] . '">
            <div class="image"><img src="' . $pic["pic"] . '"
                   alt="' . $alt["alt"] . '" 
                   height="' . $height["height"] . '" 
                   width="' . $width["width"] . '" 
              />
            </div>
          </a>
          <div class="timeago">
            <abbr class="timeago" title="' . $time["time"] .'">
           </abbr>&nbsp;in <a href="/' . $folder["folder"] . '">
           <span class="filedat">' . $filed["filed"] . '</div></a>
          </div>
        </td>'; 
    }
    $cell++;
  }
  echo '</tr></table></div>';
?>

I’m a noobie, and I have no idea why this code is only picking up the first row in my mysql database. Here’s what I mean.
My phpmyadmin db looks like:

thumbnailID |    link    |     pic     |   alt   | time | height | width | folder | filed
     1           blog      random.png    descrip   3:45    300      200      emm     weewr 
     2           about      etc.png      desc      4:15    130      150      wer     ewrre
     3           misc       er.png        desc     2:30    324      435      sdf     dcv
     4           misc        etc.png      info     6:50    203      034      sdf      qwd
     5           about       meh.png       whoa    10:12   395      234      tb      asd

So as you can see, there is five different rows. But for some reason, row 2,3,4, and 5, all have the same link, alt, time height, width, folder, and filed, as row 1. The only thing different is the pic.

For if this sounds confusing, but I don’t know how to put it in any other way.

  • 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-22T19:18:34+00:00Added an answer on May 22, 2026 at 7:18 pm

    You are issuing multiple mysql_query requests, which always resets the pointer to the first row. But mysql_fetch_array is to be used in a loop. It also queries for rows, not column-wise.

    $result = mysql_query("SELECT * FROM thumbs");
    while ($row = mysql_fetch_assoc($result)) {
    
        print "   <td> $row[link] + $row[pic] + $row[alt] ";
    
        // use only the loop variable here, not the static request arrays
        // from before
    }
    

    Your problem is that you are using previous result arrays $link[], $pic[], $alt[], $width[], $height[] for your output code – where you should be using just $row (or $pic in your code).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP: $SQL = SELECT goodies FROM stash WHERE secret=' . str_replace(','',$_POST['secret']) . '; Could
PHP has a very nice function, isset($variableName). It checks if $variableName is already defined
php newbie here..I need some PHP help ideas/examples on how to import data from
PHP Version: 5.3.3 I'm using the SOAP extension to pull data from a web
PHP has a great function called htmlspecialcharacters() where you pass it a string and
PHP's explode function returns an array of strings split on some provided substring. It
PHP, as we all know is very loosely typed. The language does not require
PHP stores its session information on the file system of the host of the
PHP treats all arrays as associative, so there aren't any built in functions. Can
PHP has a number of opcode caches, which as i understand it are scripts

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.