please help in php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
red
Forum Newbie
Posts: 18
Joined: Fri Apr 06, 2007 1:27 am

please help in php code

Post by red »

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 :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<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 : &nbsp;&nbsp;
<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>
2nd form modify.php

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]
lanasa
Forum Newbie
Posts: 14
Joined: Mon Mar 26, 2007 7:49 am
Location: Buffalo, NY

Re: please help in php code

Post by lanasa »

You'll also need to grab the 'id' from the database record and send that with your form:


// get record id from database
<input type="hidden" name="id" value="<?= $record_id; ?>" />
Post Reply