问题描述:

I have a form on a single page, if it don't have a id I want it to insert. but if there is an id then update.

I am having difficulties getting the form values to display in the button.

I am also not sure my if or else if statement is plausible.

<?php

function myform(){

if(isset($_POST['add'])) {

if ($myform_id > 0) {

//my insert query here

$btn_value = "add";

$btn_name = "add";

}elseif(isset($_POST['edit'])){

//my update query here

$btn_value = "edit";

$btn_name = "edit";

}

}

}

?>

My form button

<input type="submit" name="<? $btn_name?>" value="<? $btn_value?>">

网友答案:

try this

<input type="submit" name="<?echo $btn_name;?>" value="<? echo $btn_value;?>">
网友答案:

within the php tag itself give the following statement

print "<input type='submit' name='$btn_name' value='$btn_value'>";
相关阅读:
Top