How can I make a database with querry...

User 2442928 Photo


Registered User
13 posts

I ask you if you know a simple and non-sophisticated system to insert a database with querry on my site?
Or if you know some interneet resources that I can consult also video.
Thanks

User 187934 Photo


Senior Advisor
20,245 posts

Hi Claudio,
What exactly do you want to insert? Form data?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2442928 Photo


Registered User
13 posts

What I really want is the second phase of the complete creation of website. By using Responsive Site Designer I can build a site but I would like to start learning how to insert the simplest things first such as a library and then start doing more complex things with sql.
I thank you Eric for your interest
User 187934 Photo


Senior Advisor
20,245 posts

Ok, Your going to need to be more specific so I can help you. Are you wanting to insert data from a form into a database or make a table from data already in a database?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2442928 Photo


Registered User
13 posts

Both ways. I want to insert data from a form into a database and make a table from data already in a database.
Thanks Eric
User 187934 Photo


Senior Advisor
20,245 posts

This is a quick example of an insert. You should do validation on the variables before insert.
<?php
$database = 'mysql: myHost =localhost;dbname=MYDATABASENAME;charset=utf8';
$username = 'USERNAME';
$password = 'PASSWORD';
try {
$pdo = new PDO($database, $username, $password);
$pdo ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo ->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$fieldone = $_POST['fieldone'];
$fieldtwo = $_POST['fieldtwo'];
$fieldthree = $_POST['fieldthree'];
$sql1=("INSERT INTO mytable (fieldone,fieldtwo,fieldthree)
VALUES (:fieldone,:fieldtwo,:fieldthree)");
$q = $pdo->prepare($sql1);
$q->execute(array(':fieldone'=>$fieldone,':fieldtwo'=>$fieldtwo,':fieldthree'=>$fieldthree));
// if successfully inserted
if($q){
header("Location: ../../mypage.php");
exit();
}
else {
echo "ERROR";
}
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2442928 Photo


Registered User
13 posts

Thanks Eric, I try to do.
User 187934 Photo


Senior Advisor
20,245 posts

After you get the insert working, I'll post an example of retrieving the data.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2187930 Photo


Registered User
9 posts

Hello Eric,

I would be interested in seeing the followup on how to retrieve the data.

I have a MySQL database that I can use for free on my website host (iPower).

I would like to show a gallery of stamps with their ID# and Price on my webpage.

I have all of the stamps listed in the database and also have a field (PicURL) that points to a .jpg picture of each stamp.

So when a user goes to the web page, I would like them to see a gallery listing (maybe 4 columns wide) that shows each stamp picture with it's ID# and Price below it.

I appreciate any help and/or samples you could give me.

Thanks,
Scott
User 187934 Photo


Senior Advisor
20,245 posts

I have an example here that has dynamic dropdowns.
https://ericrohloff.com/coffeecup/ccfor … _data.html
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.