Re: Adding records to a MySql database
| From: | Dave.O | Date: | Fri, 17 Aug 2001 23:52:39 +0000 |
| Subject: | Re: Adding records to a MySql database | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63263@lists.php.net to get a copy of this message | ||
Thanks
----- Original Message -----
From: "Martín Marqués" <martin@bugs.unl.edu.ar>
To: "Dave.O" <Dave.O@tinyonline.co.uk>
Cc: <php-general@lists.php.net>
Sent: Saturday, August 18, 2001 12:43 AM
Subject: Re: [PHP] Adding records to a MySql database
> On Vie 17 Ago 2001 20:39, Dave.O wrote:
> > No offence but you are telling me stuff I already know ! This mailing
> > list is very good so dont take offence due to my frustration. I know
how
> > to connect to the server, create the database and more or less query it,
> > but cant find the command to add/insert records or am I doing something
> > very wrong. I presume this can be done in php
>
> I don't use MySQL, but I'll give you an example.
>
> Lets say you have a table in your database like this:
>
> col1 INT (autoincremental)
> col2 VARCHAR(50)
>
> and say the name of the table is tab1
>
> if you want to insert a new row with value 'Dave the great!' whihc is
loaded
> in the $var1 variable, you just have to do this:
>
> $query="INSERT INTO tab1 (col2) VALUES (" . $var1 . ")";
>
> query_func($query);
>
> All this after you have connected to the database with the connection
> function of the MySQL extension.
>
> So, if the query went OK, you have a new record in the database with some
> value in the col1 (integer type) and 'Dave the great!' in col2.
>
> Undestand?
>
> --
> Porqué usar una base de datos relacional cualquiera,
> si podés usar PostgreSQL?
> -----------------------------------------------------------------
> Martín Marqués | mmarques@unl.edu.ar
> Programador, Administrador, DBA | Centro de Telematica
> Universidad Nacional
> del Litoral
> -----------------------------------------------------------------
>