PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jul 25, 2017 9:41 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jun 14, 2017 12:15 pm 
Offline
Forum Newbie

Joined: Wed Jun 14, 2017 12:07 pm
Posts: 1
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


<?php

include_once 'con_ui.php';
if(isset($_POST['btn-save']))
{

$advertiser = $_POST["advertiser"];
$impressions = (isset($POST["impressions"])?
$_POST["impressions"]:'');



$sql_query = "INSERT INTO data(adv, imp) VALUES('$advertiser', '$impressions')";
mysql_query($sql_query);

// sql query for inserting data into database

}
?>


<html>
<head>
</head>
<body>
<form method="post">
<table id="myTable" align='center' cellspacing=0 cellpadding=5 border=1>

<tr>
<th>advertiser</th>
<th>impressions</th>
</tr>
<td>

<select name="advertiser" id="advertiser">
<option value="">Select advertiser</option>
<option value = "Brita ">Brita</option>
<option value = "Sammontana">Sammontana</option>
</select>

</td>

<td name= "impressions" id="impressions" >1000000</td>

<td>
<button type="submit" name="btn-save"><strong>SAVE</strong></button>
</td>
</form>
</body>
</html>
---------------------
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;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group