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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:19:08+00:00 2026-05-30T04:19:08+00:00

I wonder whether someone may be able to help me please. I’m using the

  • 0

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

I’m using the code below to construct a list with a radio button as a way of selecting each row of data.

<?php

mysql_connect("hostname", "username", "password")or
die(mysql_error());
mysql_select_db("database");



$result = mysql_query("SELECT userdetails.userid, finds.userid, finds.locationid, detectinglocations.locationid, detectinglocations.locationname, finds.dateoftrip, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1");
if (mysql_num_rows($result) == 0)
// table is empty
  echo 'There are currently no finds recorded for this location.';
echo"<table>\n";
  while (list($userid, $dateoftrip) =
    mysql_fetch_row($result))
  {

    echo"<tr>\n"
    .
     "<td><input type='radio' name='radio' dateoftrip, value='{$userid}' /></td>\n"
    ."<td><small>{$dateoftrip}</small><td>\n"
    ."</tr>\n";
  }
  echo"<tr><td colspan=\"3\">";
  echo"<br>";
  echo"</td></tr>";
  echo'</table>';

?>

I can manage to construct the list but the value next to the radio button is the ‘userid’ whereas I’m looking to put the ‘dateoftrip’ against each radio button.

I’ve been working on this for a while now and I can’t see where my error is.

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

Many thanks

  • 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-30T04:19:10+00:00Added an answer on May 30, 2026 at 4:19 am

    mysql_fetch_row() returns a numeric-indexed array from the result resource having fields in the same order as you selected them. Since your SELECT list’s first 2 fields are userdetails.userid, finds.userid, those are the two returned back to your list() call.

    Instead, it’s easier to use mysql_fetch_assoc(). You could user mysql_fetch_row() and figure out the numeric indices of the two columns you need, but that’s difficult. In the best situation, you would only include the two columns you actually need in your SELECT in the first place, which would cause your code to work correctly.

    while ($row = mysql_fetch_assoc($result)) {
      $userid = $result['userid'];
      $dateoftrip = $result['dateoftrip'];
      // etc...
    }
    

    Note, that since you’re fetching two columns called userid from different tables, you should create aliases for them to differentiate them after fetching:

    // Aliases for userdetails.userid, finds.userid:
    $result = mysql_query("SELECT userdetails.userid AS userid, finds.userid AS findsid, finds.locationid, detectinglocations.locationid, detectinglocations.locationname, finds.dateoftrip, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1");
    
    • 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. Using some excellent
I wonder whether someone may be able to help me please. I am using
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'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. 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've put some
I wonder whether someone may be able to help me please. I'm wanting to

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.