Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello ,im a newbie here. I just have some questions regarding how to pass selected values from a PHP generated combo box. I have 3 PHP-generated combo boxes, the values of which come from the database, This is my code :Code: Select all
<form id="form1" name="form1" method="post" action="saveMix.php">
<table width="279" border="0">
<tr>
<th width="51" scope="row">Copy</th>
<td width="218"><label>
<?php
connectDB();
getCopies(); ?>
</label></td>
</tr>
<tr>
<th scope="row">Volume</th>
<td><label>
<?php
connectDB();
getVolumes(); ?>
</label></td>
</tr>
<tr>
<th scope="row">Issue</th>
<td><label>
<?php
connectDB();
getIssues(); ?>
</label></td>
</tr>
.....
function getIssues(){
$query = "select distinct issue from magazines order by issue";
$result = mysql_query($query);
echo " <select name='issues'> ";
while ($row = mysql_fetch_assoc($result))
{ extract($row);
echo "<option value=>$issue</option>";
}
mysql_close();
echo "</select>";
}
function getCopies(){
$query = "select distinct copy from magazines order by copy";
$result = mysql_query($query);
echo " <select name='copies'> ";
while ($row = mysql_fetch_assoc($result))
{ extract($row);
echo "<option value=>$copy</option>";
}
mysql_close();
echo "</select>";
}
function getVolumes(){
$query = "select distinct vol from magazines order by vol";
$result = mysql_query($query);
echo " <select name='volumes'> ";
while ($row = mysql_fetch_assoc($result))
{ extract($row);
echo "<option value=>$vol</option>";
}
mysql_close();
echo "</select>";
}Code: Select all
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$conn = mysql_connect($host, $user, $pass) or die ('Error connecting to mysql');-
print mysql_error();
$dbname = 'archives';
mysql_select_db($dbname);
$copy=$_GET['copies'];
$type=$_POST['types'];
$issue=$_POST['issues'];
$volume=$_POST['volumes'];
$type=$_POST['types'];
$author=$_POST['authors'];
$topic=$_POST['topic'];
$details=$_POST['details'];
$query = "insert into mix values('" . $copy . "','" . $volume . "','" . $issue . "','" . $type . "','" . $author . "','" . $topic . "','" . $details . "')" ;
$result = mysql_query($query); //blah blah blah..Need help pls ASAP. Thank you and more power.
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]