SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Feb 24, 2004, 07:38 #1
- Join Date
- Feb 2004
- Location
- ireland
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sending multiple copies to database
Hi,
I am trying to send multiple copies of information on a form to a mysql database using a quantity field on the form, each copy having a different id.
if(!$title)
{?>
<form Name=addStock METHOD="post">
<p> Title: <input type="text" name="title"> </p>
<p> Year: <input type="text" name="releaseYear"> </p>
<p> Quantity: <input type="text" name="a"> </p>
<button type="submit" >ADD</button>
</form>
<?
}
else
{
$query = "INSERT INTO test(title, releaseYear) VALUES ('$title', '$releaseYear')";
echo"<p>$title has been added to your database</p>";
$result = mysql_query($query);
}
?>
I have tried putting for and while loops around the query but no luck it either loops infinitely or doesnt work. Any ideas?? Thanks
-
Feb 24, 2004, 07:40 #2
your form is completely wrong!!!
u have to use $_POST attribute to insert to mysql function!
HTML Code:<form Name="addStock" METHOD="post"> Title:<input type="text" name="title"><br> Year: <input type="text" name="releaseYear"><br> Quantity: <input type="text" name="a"><br> <input type="submit" name="update" value"ADD"> </form>
PHP Code:<?php
if(isset($_POST["update"])) insert_data();
function insert_data()
{
if($title!="")
{
$ret= "INSERT INTO test VALUES('', '$title', '$releaseYear')";
echo"$title has been added to your database<br>\n";
$resultat = mysql_query($ret);
}
}
?>
cya
Bookmarks