Re: Php code in html buttons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

What about this.

test.php
<?php

if(isset($_REQUEST['sqlProcess']))
{
switch($_REQUEST['sqlProcess'])
{
case "query1":
$sql="
SELECT FOO
FORM BAR
WHERE BAZ='BAR'"
break;
}
$res =  mysqli_query($connect,$sql);
}
if(!isset($res))
{
$strReturn = 
"<form name='test' method='post' action=''>
<input type='submit' name='submit' value='click' />
<input type='hidden' name='sqlProcess' value='query1' />
</form>"
}
else
{
$strReturn =
"do whatever want to with your mysql result";
}
echo $strReturn;
?>

Hope helps.

To ajaxing this page please look
www.xajaxproject.org

Regards

On Wednesday 11 July 2007 01:59:42 k w wrote:
> I'm trying to make a button execute some php code when the button is
> clicked. I'm not sure if it is the button i'm coding wrong or the php code.
> Here is the code I am using.
>
> <?php
> echo "<button action='<?php
> mysqli_query($connect,$query)?>'Click</button>"; ?>
>
> I've got all my variables stored in the php page, and I know they are all
> correct. But when I push the button it does nothing. I'm not quite sure
> what I am doing wrong.
>
> I have also tried
>
> <input type=button value="Click" OnClick= "<?php
> mysqli_query($connect,$query); ?>">
>
> and
>
> <form onclick="<?php mysqli_query($connect,$query); ?>">
> <input type=button value="Click">
> </form>
>
> Obviously i'm a complete newbie. I'd appreciate any help. Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux