Jump to content

Recommended Posts

Hi all,

 

I have a drop down reading from a table in the database.

 

When I select the option from the drop down i would require this information to be passed over to another page.

 

Can I use a link? If so is what I am doing correct?

 

Please see the code I'm using below...

 

drop down for category:

 

<p>Select an existing industry:<br />

<select name="categories">

<?php

$selectCategoryQuery = "SELECT * FROM categories ORDER BY categoryname";

$selectCategoryResult = mysql_query($selectCategoryQuery) or die(mysql_error());

 

while($row1Category=mysql_fetch_array($selectCategoryResult))

{ ?>

 

 

<?php echo '<option value="'.$row1Category['categoryid'].'">'.$row1Category['categoryname'].'</option>'; ?>

   

 

<?php }

?>

 

Then I was wondering how to pass the details to another page using a link??

 

<a href="addbrieftocategory.php?categoroyid=<?php echo $row['categoryid']?>" >[+] </a>

 

Which then takes me to another page where I can insert this id into a database table.

 

Can someone please advise me.

 

Thanks in advance

 

 

 

 

Hi,

 

Ok I understand that but maybe I have made a mistake in my code because I can't display the category id or write it to the db.

 

Here is the code I'm using:

 

Form:

 

<form action="addbrieftocategory.php" method="get">

           

                <p>Select a category:<br />

<select name="categories">

<?php

$selectCategoryQuery = "SELECT * FROM categories ORDER BY categoryname";

$selectCategoryResult = mysql_query($selectCategoryQuery) or die(mysql_error());

 

while($row1Category=mysql_fetch_array($selectCategoryResult))

{ ?>

 

 

<?php echo '<option value="'.$row1Category['categoryid'].'">'.$row1Category['categoryname'].'</option>'; ?>

   

 

<?php }

?>

   

</select>

                    <input name="Save" type="submit" value="Upload">

             

                    </form>

 

Then the page the action goes to:

 

<?php

session_start();

require "connect.php";

 

          $briefid = mysql_insert_id($connection);

        $categoryid = $_GET['categoryid'];

     

        echo $categoryid;

 

 

      $query = "insert into briefcat values ('".$briefid."','".$categoryid."') ";

      $result = @mysql_query($query, $connection)or die ("Unable to perform query<br>$query");

 

        //header("Location: briefsassignedto.php");

//exit();

        ?>

 

Is this correct?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.