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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:05:48+00:00 2026-06-06T11:05:48+00:00

I wonder whether someone may be able to help me please. I feel I

  • 0

I wonder whether someone may be able to help me please.

I feel I need a fresh pair of eyes to look at a problem I have which I can’t see a solution to.

The form below is used to list Location records held in a MySQL database.

    <form name="locationsconsole" id="locationsconsole" method="post" action="locationsaction.php">

                                    <?php

                                        $query = "SELECT * FROM `table` WHERE `userid` = '$idnum' ORDER BY locationname";
                                        $result = mysql_query($query) or die('error');
                                        $num = mysql_numrows($result);
                                        mysql_close($connect);                  
                                        $i=0;
                                        while ($i < $num) {
                                        $lid=mysql_result($result,$i,"locationid");
                                        $lname=mysql_result($result,$i,"locationname");
                                        $laddress=mysql_result($result,$i,"returnedaddress");

                             <tr>
                                <td><input type="text" id="lid" name="lid" value="<?=$lid?>"/></td>
                                <td><div align="center"><?php echo $lname;?></div></td>
                                <td><div align="left"><?php echo $laddress;?></div></td>
                                <td><div align="center"><?php echo $findscount?></div></td>
                                <td><div align="center"><input name="type" type="submit" value="View Details"/></div></td>
                                <td><div align="center"><input name="type" type="submit" value="Add Finds"/></div></td>
                                <td><div align="center"><input name="type" type="submit" value="Add Images"/></div></td>
                                <td><div align="left"><input name="type" type="submit" value="View Location Finds"/></div></td>
                            </tr>

    </form>

Using the code below, the four buttons at the end of my form take the user to four separate screens, all linked back to the Location record via the $lid variable.

<?php session_start();
$_SESSION['lid'] = $_POST['lid'];
if (isset($_POST['type'])) {
    $urls = array(
        'View Details' => 'viewlocation.php',
        'Add Finds' => 'addfinds.php',
        'Add Images' => 'addimages.php',
        'View Location Finds' => 'locationfinds.php'
    );
    $url = $urls[$_POST['type']];
    header("Location: " . $url);
}
?>

All of the four receiving forms therefore have this $lid = $_SESSION['lid']; at the top of each page to capture this variable.

This architecture worked perfectly up to a few days ago, and it’s now all gone awry and I’m not sure why. I know that this field <input type="text" id="lid" name="lid" value="<?=$lid?>"/> in my form is holding the correct value.

However, irrespective of how many Locations records there are, if I click on any button I’m taken to the correct receiving screens, but it’s always for the last ‘Location` record in the list.

I just can’t seem to find what I’m doing wrong here, or understand why it’s now started to cause me problems. I’ve checked the JavaScript console in Chrome, and that’s not showing me any errors either.

I just wondered whether someone could perhaps take a look at this please an let me know where I’m going wrong.

Many thanks and kind regards

  • 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-06T11:05:50+00:00Added an answer on June 6, 2026 at 11:05 am

    All of your “lid” inputs are in the same form. When you submit your form, all values are sent and only the last one get into your $_POST array. Move form tags to the inside of your loop (that means generate many forms) ant it should work fine.

    <?php
    
    $query = "SELECT * FROM `table` WHERE `userid` = '$idnum' ORDER BY locationname";
    $result = mysql_query($query) or die('error');
    $num = mysql_num_rows($result);
    mysql_close($connect);
    $i = 0;
    while ($i < $num) {
        $lid=mysql_result($result,$i,"locationid");
        $lname=mysql_result($result,$i,"locationname");
        $laddress=mysql_result($result,$i,"returnedaddress");
    
        ?><form name="locationsconsole" id="locationsconsole" method="post" action="locationsaction.php">
            <table>
                <tr>
                    <td><input type="text" id="lid" name="lid" value="<?=$lid?>"/></td>
                    <td><div align="center"><?php echo $lname;?></div></td>
                    <td><div align="left"><?php echo $laddress;?></div></td>
                    <td><div align="center"><?php echo $findscount?></div></td>
                    <td><div align="center"><input name="type" type="submit" value="View Details"/></div></td>
                    <td><div align="center"><input name="type" type="submit" value="Add Finds"/></div></td>
                    <td><div align="center"><input name="type" type="submit" value="Add Images"/></div></td>
                    <td><div align="left"><input name="type" type="submit" value="View Location Finds"/></div></td>
                </tr>
            </table>
        </form><?php
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. Using some excellent
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please. From some demos
I wonder whether someone may be able to help me please with a error
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. I've put together

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.