form action dropdown help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
melindaSA
Forum Commoner
Posts: 99
Joined: Thu Oct 02, 2003 7:34 am

form action dropdown help

Post by melindaSA »

I have a dropdown that is been populated from a database table, however I don't know how to show the results....

here is my code

Code: Select all

<?php
$query = "SELECT catID, category from category ORDER by catID";
$result = mysql_query($query)
    or die ("Couldn't execute query.");
    
    //create form containing selection list


             echo "<form action='show_category.php?$catID=['catID']' method='post'>
                   <select name='category'>\n";

                while ($row = mysql_fetch_array($result))
                {
                     extract($row);
                     echo "<option value='$category'>$category\n";
                }
                echo "</select>\n";
                echo "<input type='submit' value='SELECT'>
                      </form>\n";
?>

?>
this is the part that is not working...

Code: Select all

<?php

echo "<form action='show_category.php?$catID=['catID']' method='post'>

?>
Am I using incorrect syntax??

This works fine if I use a url list

Code: Select all

<?php
$url = 'show_category.php?catID='.($row['catID']);

?>
HELP!!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Note that in the working example you have:

Code: Select all

catID='.($row['catID'])
and in the non-working example

Code: Select all

$catID=['catID']
Try changing

Code: Select all

echo "<form action='show_category.php?$catID=['catID']' method='post'> <select name='category'>\n";
to

Code: Select all

echo '<form action="show_category.php?catID='.$row['catID'].'" method="post"> <select name="category">'."\n";
Mac
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

checnge the bit that isn't working to

Code: Select all

<?php 

echo "<form action='show_category.php?catID=".$row['catID']."' method='post'> 

?>
Should solve your problem

Mark
melindaSA
Forum Commoner
Posts: 99
Joined: Thu Oct 02, 2003 7:34 am

Post by melindaSA »

Thank you, But it is still not working, I get the following in the url of the results page: http://www.bjrh.org/HRjobs/show_category.php?catID=


Must be an error in the show_category.php:

Can you see a problem here:

Code: Select all

<?php
include ('positions_inc_fns.php');
    // This application needs sessions, so start one
    session_start();
    $catID = $HTTP_GET_VARS['catID'];
    $name = get_category_name($catID);
   
    do_html_header($name);
  
    // get the position info out from db
    $pos_array = get_positions($catID);
  
    display_positions($pos_array);

?>
thank you sooo much for your help!
Post Reply