Jump to content

if someone can explain me few thing....


nec9716

Recommended Posts

there few thing I still not understand

 

<input type:hidden....what hidden do exactly?

 

I don't want to post all my script ( kind of long )

but in this script what $handle do ?

 

function show_form($handle='',$data='')

{

$name = '';

$team = '';

$id = '';

$value = 'Add'; //submit button value

$action = 'add'; //default form action is to add a new kid to db

 

//set the action based on what the user wants to do

if ($handle)

{

//set form values for button and action

$action = "edit";

$value = "Update";

 

//get the values from the db resultset

$row = mysql_fetch_array($handle);

 

$name = $row['name'];

$team = $row['team'];

$id = $row['id'];

}//end if

 

//error handling from the processing form function

if($data != '')

{

$elements = explode("|",$data);

$name = $elements[0];

$team = $elements[1];

$id = $elements[2];

}

?>

<body>

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action?>">

<table width="60%" align="center" border="0" cellspacing="0" cellpadding="0">

<tr>

<input type="hidden" value="<?php echo $id?>" name="id">

</tr>

<tr>

<td align="right">Name: </td>

<td><input name="name" type="text" value="<?php echo $name?>"> </td>

</tr>

<tr>

<td align="right">Team Name: </td>

<td><input name="team" type="text" value="<?php echo $team?>"> </td>

</tr>

<tr>

<td colspan="2" align="center"><input name="submit" type="submit" value="<?php echo $value?>">

<input name="reset" type="reset" value="Clear Form"></td>

</tr>

</table>

</form>

</body>

<?

}//end function

Link to comment
https://forums.phpfreaks.com/topic/99261-if-someone-can-explain-me-few-thing/
Share on other sites

1/ Hides the form element from display.

2/ Pretty hard to read your code because there is no indentaion and you failed to post your code in the provided


tags but, it would appear it doesn't do much. If you pass this function anything as its first argument ($handle) then $action will be set to edit and $value will be set to Update otherwise they are both set to the default of add.

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.