|PHP Developers Network
|how to push data from html grid to mysql?
|Page 1 of 1|
|Author:||a.longo [ Wed Jun 14, 2017 12:15 pm ]|
|Post subject:||how to push data from html grid to mysql?|
I am trying to push the data from this simple html grid into mysql but I can't do it. in the beginning, I got the error that there was no index for the var impressions. I fixed that. when I use just the advertiser value I can push the data into mysql while with the second value, I can't succeed. can you explain me what I am doing wrong? here you can find my html code and as well the query i used to create the db. sorry if the questions is dumb, just a beginner
$advertiser = $_POST["advertiser"];
$impressions = (isset($POST["impressions"])?
$sql_query = "INSERT INTO data(adv, imp) VALUES('$advertiser', '$impressions')";
// sql query for inserting data into database
<table id="myTable" align='center' cellspacing=0 cellpadding=5 border=1>
<select name="advertiser" id="advertiser">
<option value="">Select advertiser</option>
<option value = "Brita ">Brita</option>
<option value = "Sammontana">Sammontana</option>
<td name= "impressions" id="impressions" >1000000</td>
<button type="submit" name="btn-save"><strong>SAVE</strong></button>
creating db here:
CREATE DATABASE `shaa` ;
CREATE TABLE `shaa`.`data` (
`user_id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`adv` VARCHAR( 25 ) NOT NULL ,
`imp` INT( 10 ) NOT NULL
) ENGINE = InnoDB;
|Author:||benanamen [ Sun Nov 12, 2017 1:30 am ]|
|Post subject:||Re: how to push data from html grid to mysql?|
Hopefully you have learned what you need to know by now.
For others running across this post, the OP has pretty much done everything you could possibly do wrong in this code. Problems include using dangerous, obsolete mysql code that has been completely removed from PHP, depending in the name of a button for the script to work instead of checking the REQUEST METHOD, creating variables for nothing, not using prepared statements, putting variables in the query, missing closing table tag, giving a name to a TD tag and expecting it to work like an input tag and submit a value, using a table for non-tabular layout instead of CSS, using deprecated HTML...........
|Page 1 of 1||All times are UTC - 5 hours|
|Powered by phpBB® Forum Software © phpBB Group