want to insert data into table on cliking a form button

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
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

want to insert data into table on cliking a form button

Post by bugthefixer »

i hav a table named 01_detail and on clicking add button i want to insert data into table ..my code is like this<input type="button" name="add" value="add" onClick="<?php
mysql_query("insert into 01_detail values(03,22,'00:00:00','00:00:00')");
?>">
when i run this query in mysql prompt it works fine but it doesnt work on cliking add button..anybody can tell me y..
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

First of all, may i suggest you read this!! - viewtopic.php?t=21171

Secondly, the code yu have written is total nonsense. You can't run PHP using a Javascript function.

You will need to submit the page, then run the query. Remember, PHP is server side, NOT client side!

Mark
Post Reply