please help in php code
Posted: Fri Apr 06, 2007 2:32 am
feyd | Please use
2nd form modify.php
feyd | 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]
Hi every body,
I hv written a php code for selecting a ID,Name from database and stored in combo box .
selecting respective ID and Name i should sumbit to next form .
which values i hv to pass to next form ,
so i can execute my update query in second form.Code: Select all
<form action="http://localhost/Admin/modify.php" method="post">
<table cellspacing="1" cellpadding="1" width="75%" align="center" border="1" bgcolor="66CCFF">
<tr>
<td>
Select the Category ID :
<select name="option1" style="font-family: Arial; color: maroon; font-size: 10pt;">
<option value="xxxx" style="font-family: Arial; color: maroon; font-size: 10pt; font-weight: bold">select</option>
<?
$res3 = mysql_query("select * from category");
while($row3 = mysql_fetch_array($res3))
{
$CatID=$row3[0];
$CID=$row3[1];
echo "<option value='$CID' style='font-family: Arial; color: maroon; font-size: 8pt; font-weight: bold'>$CatID</option>";
}
?>
</select>
Select the Category Name :
<select name="option2" style="font-family: Arial; color: maroon; font-size: 10pt;">
<option value="xxxx" style="font-family: Arial; color: maroon; font-size: 10pt; font-weight: bold">select</option>
<?
$res3 = mysql_query("select * from category");
while($row3 = mysql_fetch_array($res3))
{
$CatID=$row3[0];
$CName=$row3[1];
echo "<option value='$CatID' style='font-family: Arial; color: maroon; font-size: 8pt; font-weight: bold'>$CName</option>";
}
?>
</select>
<input type="submit" name="submit" value="submit">
<input type="Reset" value="Reset" size="20">
</td>
</tr>
</table>
<br>
</form>Code: Select all
<?php
// Set global variables to easier names
$cid=$HTTP_POST_VARS["CatID"];
//$cid = $_POST['xxxx'];
$cname = $_POST['CName'];
$query ="UPDATE category SET CName='$cname' where CID = '$cid'";
$result = mysql_db_query($db_name,$query);
if (!$result) {
echo("ERROR: " . mysql_error() . "\n$query\n");
}
else
{
echo ("New Link Added\n");
$q ="select * from category";
$r = mysql_db_query($db_name,$q);
echo "<tr> CID CName ";
while($row = mysql_fetch_array($r))
{
echo " \n";
echo "\n " . $row['CID'] . " ";
echo "\n " . $row['CName'] . " ";
echo " \n";
}
}
mysql_close( $link );
?>feyd | 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]