How To Make A MySQL Database

gimme4free

Elite Member
Joined
Oct 22, 2008
Messages
1,935
Reaction score
1,989
OK, Im a complete noob when it comes to MySQL so I'm looking for a bit of help.

I have been asked to design an order form by a friend that must be online so Microsoft Access / Excel is a no-no.

The order form must be able to lookup products by their code

E.g. If I click on product code and type in a product code and then leave that box it will look up the product name from the DB and automatically insert it into the product box.

Preferably the online form should be in an excel type form, not full page though so Im not sure if it is possible to do with a DB / Excel / Access.

Yes, I know this is a bit vague but I cannot find any good examples lol.

If anyone has any ideas on how to create this with PHP/MySQL or if they have any suggestions as to what else would be suitable that would be great :D
 
sounds like a job for mySQL for sure. It's not that easy to just 'let you know how'. You have to know PHP and mySQL. Or you have to hire someone like me who does. :) Even if I tried to tell you here, it would look like greek. Not something you can learn in a day.
 
lol I know PHP but the second it comes to connecting it to MySQL I feel like Im listening to a Chinese man speaking lol.

At the moment I store data in PHP files, e.g. (product1.php) <?php $P0001 = "Product 1" ?> and then use include "product1.php"; and then relate to it again as <?php echo "$P0001" ?>

Or obviously store the whole product list in product.php but I can see that when having 1000+ products it is going to get messy lol.
 
If you don't want to use mySQL, I am pretty sure you can use XML, which is easy to learn and you can learn it in about 15 minutes. Maybe less. w3schools.com has a step by step tutorial. I haven't tried using XML with PHP because I do know mySQL, which is just better for this sort of thing. There may be some preprogrammed SQL databases for ecommerce type operations that you can look for. Probably will cost money though.
 
look mate its simple. php and mysql are things u need to be capable of using. so the best way to start is to take that title of the thread and put it into google. now u go and practice and learn about setting up a mysql database. and later how to use php to connect with it. u can learn that online. or u go and buy a book about it. its that easy...

and dont say u know php when u cannot use it with a database..
 
Just PM'd you - email me the details as per the PM and I'll send you back the code. I'm getting so much from BHW I need to start giving back a bit more

Cheers

Ronin
 
Thanks a lot ronin, will knock up an example in word :D

Thanks for the reply also sophia, was actually looking to see if there was a quick, easy option for something like this as learning MySQL may take a little while lol.
 
Like s0phia said, google is your friend.

-Use phpmyadmin (there's other stuff but usually this is bundled with cpanel) to make your database, table, and fields (you may need to google the description of some types such as int, text, varchar, etc based on what you need)
-Google for 'mysql and php' to find out how to figure out how to connect to database with php
-Google 'mysql search' for the function you need
-"Leaving the box..." sounds like a javascript function. Not sure how easy it is to make javascript call a php function to call up the database search, but a form submit button may be easier to fill in the product info box after you type in the id.
 
If you still need some help you can PM me as well, will try to help :)
 
how many products are you looking at?

you might actually be better off using something like joomla/virtuemart so as you can add lots more variables and have a relatively easy to use GUI already designed for it...

just a thought....

either way php/mysql is the way to go :)
 
Ukescuba - Probably around 1000 products, would consider a GUI but to be honest I'm happy with a couple of pages. 1) Shows orders, 2) Writes orders. Sounds quite simple to me but when I look at MySQL it does not look so simple lol.

As with Joomla or any other GUI all of the products will have to be entered manually anyway so the only upside would be that it is something that has already been created, downside that I wont use 99% of it which may make it look a bit messy or make a simple script very complicated.

Thanks for all the help guys :D
 
something like this can be used to enter information in the table

Code:
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

// Insert a row of information into the table "example"
mysql_query("INSERT INTO $table 
(product name, product code ) VALUES('$productname', '$productcode') ") 
or die(mysql_error());  
  
mysql_close();

don't know how to do the forms though
 
also
Code:
h**p://w3.tizag.com/mysqlTutorial/mysqlselect.php
should be able to help you on displaying information from a table
 
Your request is vague but I did my best! :)

I knocked up a rough draft in a few minutes, you can expand and advance on this, this will basically get your raw data in a mysql table, commerce. I will include a keymap at the bottom so you can change the variables in the script appropriately. This isn't advanced by any means of course!​

signup.php

PHP:
<?php

//order f o r m
//submit form signup.php

echo 'Lipsum random text and details';

<input type="text" name="productname"> 
<input type="text" name="firstname">
<input type="text" name="lastname">
 <input type="text" name="email"> 
<input type="submit" value="Send"
<form action="step2.php" method="post">
</form>

?>

step2.php

PHP:
<?php

//inserting to mysql now, this is step2.php

mysql_select_db("yourDatabaseName", $con); //Replace with your MySQL DB Name
$productname=mysql_real_escape_string($_POST['productname']); //This value has to be the same as in the HTML form file
$firstname=mysql_real_escape_string($_POST['firstname']); //This value has to be the same as in the HTML form file
$lastname=mysql_real_escape_string($_POST['lastname']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO commerce (firstname,email,productname,lastname) VALUES ('$firstname','$email','$productname,'$lastname')";

<html redirect to list.php>

?>

list.php

PHP:
<?php

//displaying mysql records now, this is list.php

mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("commerce") or die(mysql_error());
$result = mysql_query( "SELECT * FROM commerce" ) 
$num_rows = mysql_num_rows($result); 
$get_info = mysql_fetch_row($result)
foreach ($get_info as $field) 

?>

yourDatabaseName = your database name
commerce = your table name
localhost = mysql server address
admin = mysql username
firstname, email, productname, lastname = fields of DB table
1admin = pass

let me know if you encounter an error.​
<html redirect to list.php> / javascript redirect/refresh to list.php
This is basically submitting a HTML form into mysql and having your script list the data.
P.S. - You have to manually create the DB, table, and fields...
 
Last edited:
Back
Top