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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:41:22+00:00 2026-06-15T00:41:22+00:00

echo ‘<td><input type=checkbox name=items[] value=’ . $row[‘0’] . ‘ /></td>’; Hi, I’m trying to

  • 0
echo '<td><input type="checkbox" name="items[]" value="' . $row['0'] .  '" /></td>';

Hi, I’m trying to get a reference number which comes from a an array called items from another page as shown above, and to find it in the table and print out the reference row, like “Title,Platform….” into another table, but I can’t seem to get it working…any help be appreciated

if (isset($_POST['items'])) {
    $n = count($_POST['items']);

    for($i=0; $i < $n; $i++){
      //  echo $_POST['items'][$i]; 
    }

    $items = array();
    foreach ($_POST['items'] as $item) {
        $items[] = pg_escape_string($con, $item);
    }

    if (!$_SESSION["selectingrows"]) {

        $item_string = "'" . implode("','", $items) . "'";

        $result = pg_query ($con, "SELECT title, platform, description, price FROM CSGames    WHERE 'refnumber' IN ($item_string)");

        while($rows = pg_fetch_assoc($result))
        {
            echo "<tr>";
            echo "<td>" . $rows['1'] . "</td>"; 
            echo "<td>" . $rows['2'] . "</td>"; 
            echo "<td>" . $rows['3'] . "</td>"; 
            echo "<td>" . $rows['4'] . "</td>";
            echo "</tr>";
        }
    }
}
  • 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-15T00:41:23+00:00Added an answer on June 15, 2026 at 12:41 am

    One thing, you need to put {} braces after your while loop.

    Here is what you are doing:

    while($rows = pg_fetch_assoc($result))
    
        echo"<tr>"; echo "<td>" . $rows['1'] . "</td>"; echo "<td>" . $rows['2'] . "</td>"; echo "<td>" . $rows['3'] . "</td>"; echo "<td>" . $rows['4'] . "</td>";
        echo"</tr>"; 
    

    By not putting braces around the code after the while statement, here is what your code really does:

    while($rows = pg_fetch_assoc($result))
    {
        echo"<tr>";
    }
    echo "<td>" . $rows['1'] . "</td>"; echo "<td>" . $rows['2'] . "</td>"; echo "<td>" . $rows['3'] . "</td>"; echo "<td>" . $rows['4'] . "</td>";
    echo"</tr>";
    

    You should always put braces in to define what code is in the while loop.

    You want your code to be something like this:

    while($rows = pg_fetch_assoc($result))
    {
        echo "<tr>";
        echo "<td>" . $rows['1'] . "</td>"; 
        echo "<td>" . $rows['2'] . "</td>"; 
        echo "<td>" . $rows['3'] . "</td>"; 
        echo "<td>" . $rows['4'] . "</td>";
        echo "</tr>";
    }
    

    Format your code neatly and properly. By doing this your code is clearer and it is much easier to notice possible mistakes like the above. Always use braces for if, while, for statements. When putting an end line semicolon ; put in a new line break. Indent your code correctly. It’s little things like formatting that make coding easier.

    Now the next problem I can see is the values you are getting from the $rows array:

        $rows['1'];
        $rows['2'];
        $rows['3'];
        $rows['4'];
    

    This is trying to get something from the $rows array which has the key of string '1'.

    Usually you access array values by index, which uses an integer beggining from 0. Or you access it by a key.

    Either you can try this:

        $rows[0];
        $rows[1];
        $rows[2];
        $rows[3];
    

    Or this:

        $rows['title'];
        $rows['platform'];
        $rows['description'];
        $rows['price'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

echo Info: <input type=\text\ name=\titel\> value=\ . $row['titel'] . \> . <br />; Why
echo $form->input('birthday', array( 'label' => 'Birthday', 'type' => 'date', 'dateFormat' => 'MDYMDY', 'value' =>
echo <input type=\text\ size=3 name=\{$item[\name\]}\/>; but following works fine echo <input type=\text\ size=3 name=\{$item['name']}\/>;
echo <tr><td><input type = 'button' value = 'Agregar' onclick = 'addrow($leaguesarray[$numofleagues])' /></td></tr></table><br />\n; I
echo $this->Form->create('AmazonMatches', array('action' => 'selectMatches')); echo $this->Form->input('option_id', array('options' => $allAmazonMatches, 'type' => 'radio')); echo
echo <td>Language</td>; echo <td><select id='language' name='language'> <option value=''>Select...</option> <option value='en_US'>English(US)</option> <option value='en_AU'>English(AU)</option> <option value='en_US'>English(UK)</option>
echo $_POST[name]; //returns the value a user typed into the name field I would
echo '<p class=post><h3>'.$result['title'].'</h3><object class=video width=95% height=55%> <param name=movie value=http://www.youtube.com/v/'.$match[0].'?fs=1&amp;hl=en_US&rel=0> </param><param name=allowFullScreen value=true></param> <param name=allowscriptaccess
echo '<img src=data:image/jpg/png/jpeg;base64,' . base64_encode( $row['image'] ) . ' height=150 />'; This is showing
echo $_POST['time'].<br/>; echo $_POST['day'].<br/>; echo $_POST['year'].<br/>; echo $_POST['month'].<br/>; I have value store like this

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.