Jump to content

How do I get the value of a drop down menu?


papaface

Recommended Posts

Hello,
I was wondering if someone can help me.
Currently I have the following code in a script.
[code]<?php

require("includes/connect.php");
/*
fields:
  id
title
author
description
article
*/
if (isset($_POST["submit"]))
{

$title = $_POST["title"];
$author = $_POST["author"];
$description = $_POST["description"];
$article = $_POST["article"];
$category = $_POST["category"];

$addtodb = "insert into article(title,author,description,article,category) values ('$title','$author','$description','$article','$category')";

mysql_query($addtodb,$con);

}

else
{
$getcats = mysql_query("select name from cat",$con);
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<label>Title: <input name="title" type="text"></label><br><br>
<label>Author: <input name="author" type="text"></label><br><br>
<label>Description: <textarea name="description" cols="60" rows="10"></textarea></label><br><br>
<label>Article: <textarea name="article" cols="60" rows="30"></textarea></label><br><Br>
<label>Select Category: <select>';
while (list($catname) = mysql_fetch_array($getcats))
{
print '<option name="category" value="'.$catname.'">'.$catname.'</option>';
}
echo '</select></label><br><br>
<input name="submit" type="submit" value="Add Article!">
</form>';
}

?>[/code]

How can I get the value of the drop down menu passed to the SQL?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.