Page 1 of 1

displaying two columns data next to each other in drop down?

Posted: Tue Apr 10, 2007 3:53 pm
by thunderstorm
Alright i got my drop down box working (see viewtopic.php?t=66215) but got some more questions. ;)

1) is there any way i can have the drop down NOT disappear when u select a race from it? atm when u pick one and hit submit it disappears.

2) I didn't realise that I have some race names that are the same, but their race lengths are different - so my drop down box looks like it has a duplicate race name as users aren't going to know which one is which.... basically, is there some way that i could somehow print the race length next to the race name in the drop down? E.g. Forest 8 (race name) - 8 miles (race length) or for the other one its Forest 8 - 5 miles...

So is it possible to effectively concatenate it? Or will this <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> up the query later??

Here's my current code:

Code: Select all

<?php
require_once('connection.php');
if (!isset($_POST['submit']))#IT should be $_POST bcoz form method is POST.
{
      $res=mysql_query("select race_name from race");
      if(mysql_num_rows($res) == 0) {
         echo "there is no data in table..";
      }
      else
      {
         echo '<form action="race_results.php" method="post"><select name="race">'; 
         while($row = mysql_fetch_array($res)) 
         {
            print '<option value = "'.$row['race_name'].'" >'.$row['race_name'].'</option>'; 
         } // endof for
         echo'</select><input type="submit" name="submit" value="submit" />
         <input type="hidden" name="submitted" value="TRUE" /></form>';
      }
}
else{
      $getrace = $_POST['race'];
      $res = mysql_query("select member.first_name,member.last_name,race.race_name,race.race_date,results.time from member,race,results WHERE member.member_no = results.member_no AND race.race_no = results.race_no AND race.race_name='".$getrace."'");
    
   if(mysql_num_rows($res) == 0) {
      echo "there is no data in table..";
   }
   
   else {
      //table header
      echo'<table align="center" cellspacing="10" cellpadding="5">
      <tr><td align="left">First Name</td>
      <td align="left">Last Name</td>
      <td align="left">Race Name</td>
      <td align="left">Race Date</td>
      <td align="left">Race Time</td></tr>';
   // fetch and print all the records
   while($row = mysql_fetch_array($res)) {
               echo'<tr><td align="left">'.$row['first_name'].'</td>
         <td align="left">'.$row['last_name'].'</td>
         <td align="left">'.$row['race_name'].'</td>
         <td align="left">'.$row['race_date'].'</td> 
         <td align="left">'.$row['time'].'</td>
         </tr>';
       }

echo'</table>';
   }
}
?>

Posted: Tue Apr 10, 2007 4:53 pm
by andym01480
Answered in original thread

Posted: Tue Apr 10, 2007 5:01 pm
by RobertGonzalez
@thunderstorm:

Image

Please do not double post. It is against the rules.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.