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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:55:03+00:00 2026-05-31T20:55:03+00:00

I have a problem here I can’t solve. I have a database of houses

  • 0

I have a problem here I can’t solve. I have a database of houses with country, location, price etc entities. I print only the countries in a table using:
while ($data = mysql_fetch_array($select))
where $select is a query that selects specific data from the db. I want to display the full information of the selected db data on a different page i have created. The problem is that i don’t know how to take the price of the data the user selected. When i get the price of the $_SESSION['counter'], its the number of the last entity of the db. . I don’t want to use javascript etc. Here’s the code of the page:

<?php
require_once 'php/core.php';    // opens the database
require_once 'php/openDB.php';  // starts the new session


$select = mysql_query("SELECT ID, Country, City FROM Houses");
$counter = 1;

echo "<form action='house_profile.php' method='get'> 
    <table width='400'>
    <tr>
    <td>No.</td>
    <td>Country</td>
    <td>City</td>";
    echo "<tr>";

while ($data = mysql_fetch_array($select))
{
    echo "<tr>";
    echo "<td>" . $counter . "</td>";
    echo "<td>" . $data['Country'] . "</td>";
//  echo "<td>" . "<a href='house_profile.php' type='submit' value='$counter'>" . $data['City'] . "</a>" . "</td>";
    echo "<td>" . $data['City'] . "</td>";
    echo "<td><input type='submit' value='info' name='" . $counter . "'></td>";
    echo "</tr>";
    $_SESSION['counter'] = $counter;
    $counter++;
}
echo "</table>
    </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-05-31T20:55:04+00:00Added an answer on May 31, 2026 at 8:55 pm

    Clarification:
    You can pass any value to house_profile.php by adding a ? to start the querystring, then the name of the variable and the value. If you want to pass the id to house_profile then the link should look like this.

        "<a href='house_profile.php?ID=" . $data['ID'] . "'>"
    

    then in house_profile.php update your query like this

        $select = mysql_query("SELECT * FROM Houses where ID = " . $_GET['ID']);
    

    Now only the entity they clicked will be available.

    FYI $counter is just the count, it’s not necessarily the ID of the entity. e.g. if you delete ID 1 your records will start from ID 2 but counter will always start with 1. So to reference your entities correctly use the database ID.

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

Sidebar

Related Questions

Can't understand what is a problem here: I have got main.cpp file where I
I have a problem with docking. Here is the thing. I hope I can
I have a problem with the Firefox browser. You can see it here .
Here is my problem : I have a list of messages which I can
Here is my problem. I have a chipmunk's rigid body (a soda can standing
I have a problem here, which I've not come across before and can't seem
I have a problem which I'm pretty sure that I can't solve without going
I have a problem here that still cannot solve, the thing is I have
I have a peculiar problem here and I can't by my life figure out
I have a problem here. I've tried searching everywhere but can't seems to find

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.