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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:26:05+00:00 2026-06-15T12:26:05+00:00

Ive got to make a web-based checkout for an assignment and have come across

  • 0

Ive got to make a web-based checkout for an assignment and have come across a problem, ive imported a database and set up the data in a table with added check boxes alongside it. I need to take the reference number (stored first in the array) onto another page using sessions. From using var_dump i cant seem to get anything from the selected from the table.
Code:

Button code

<p><tr>
<input type="submit" name="Select" id="Select" value="Add Selected To Cart"/>  
</tr></p>

Access database code(values changed for saftey)

<?php
Accesses database
$con=pg_connect("host=hostname port=portnumbers
    dbname=name user=user password=password");
    if (!$con)
    {
        die('Could not connect to database');
    }
?>

Database display

//Creates table
echo "<table border='1'>\n<thead>\n<tr>\n";
echo "<th>Title</th>
<th>Platform</th>
<th>Description</th>
<th>Price</th>
<th>Buy</th>\n";

while($row = pg_fetch_array($res)){
echo"<tr>";
echo "<td>" . $row['1'] . "</td>";
echo "<td>" . $row['2'] . "</td>";
echo "<td>" . $row['3'] . "</td>";
echo "<td>" . $row['4'] . "</td>";
echo '<td><input type="checkbox" name="selected[]" value="' . $row['0'] .  '" /></td>';      
  echo"</tr>";    
  }

echo"</table>";
?>
  • 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-15T12:26:07+00:00Added an answer on June 15, 2026 at 12:26 pm

    Well, I think you can as follow because you are trying to improve a shopping car:

    //Use the `$_SESSION` var to hold the values
    foreach ($_POST['selected'] as $item)
        $_SESSION['cart'][$item] = $item; 
    

    As the item’s id will be indexed, each time a submit is performed:

    • If the item exists, will be replaced
    • If the item does not exist, will be added

    In order to remove items, you should use a “view cart” page and then show the items:

    foreach ($_SESSION['cart'] as $item)
        echo '<a href="delete-item?id=' . $item . '">' . $item . '</a>'; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem with this situation (i'll try to make it easier) -
I've got a PHP-based web app that runs on all kinds of my customer's
first I got JSON data via web server just like $.getJSON(url,function(){ //my callback function;
I'd like to be able to make the JavaScript I've got in a web
I have my 1and1 hosted web site. I've got server-side php I need to
Ok, so I have a bunch of async web service calls that I make
i've got an android app and a really simple web service that make an
I've got a really frustrating problem with a web application I work on (I
I have got a list of many web page URLs.. and all of them
I've Inheritted a large Java Web project which I've got to make some modifications

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.