Solved

Insert data into postgres Database script needed

Posted on 2011-03-09
2
514 Views
Last Modified: 2012-05-11
Hi all,

I need some simple code that does just the following:

Hope the below describes what I need:

<a href="">Save to Database Table</a> //A link here to activate the saving

var $value1='200';  
var $value2='blablabla';

etc...

...then something like:

pg_query("INSERT INTO myTable VALUES ('$value1','$value2','$fvalue3','$value4')");

echo 'Data has been saved';

//the end

Can anyone help put a script together to do the above please?

Thanks


0
Comment
Question by:error77
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35081642
Maybe like this:

<?php

if(isset($_GET[save]) && $_GET[save] == 1){
$conn = pg_pconnect("dbname=yourdb");
$query = "INSERT INTO myTable VALUES ('$value1','$value2')";
pg_query($conn, $query);
echo"saved";
}
?>

<?php
    var $value1='200';  
    var $value2='blablabla';
    
    echo"values: v1: $value1, v2: $value2";
?>

<a href="index.php?save=1">Save to Database Table</a> //A link here to activate the saving

Open in new window

0
 

Author Closing Comment

by:error77
ID: 35083799
Perfect! thanks a lot.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now