Forum Moderators: phranque
Would like to create a simple database that contains 4 columns
PN MSRP Discount_Rate Sale_price
I took a look at mysql and phpmyadmin, I understand how to make the calls from the website to the database to return the appropriate value but struggling with the database side of things.
Can I create an .cvs or .txt or excel file and upload it to the mysql or what is the simplest way to create the database?
Thanks
with phpmyadmin you can insert data from a text file on your hard drive. Don't use a tab delimited - use something else to delimit.
When making the fields you'll have to tell mysql what kind of data is going in what field/column. That's the column types (varchar, smallint, etc) You'll have to read up on that at the mysql site
If you have your data in excel, and the data itself doesn't have commas you can save the excel file as csv and tell phpmyadmin you are delimited with comma's on the upload. Just keep a copy of the excel file as .xls too.. cause it does weird things when you try to open that .csv file again in excel... you know - excel tries to format everything for you.
If anybody has better ideas on how to move data around, edit it and re-upload it than excel I'm all ears - cause I have 20,000 plus rows at a time to dump and mess with.
Can someone tell me how to write the html code for the website or give me an example?
The table looks like this:
partnumber msrp discount saleprice
abc 100 10 90
Would need to call the database and search for the pn and then return the salesprice?
Thanks for your help.
Just edit this script for your particulars & stick it in any html doc inside the body tag. You HAVE to rename the file whatever.php instead of whatever.htm
This is about as simple as it gets... you can do a lot more w/ php... try to think like a lazy person who wants the computer to do all the work, and you will get along fine with php
<?php
$link = mysql_connect ("localhost", "user", "pass")
or exit ("could not connect to mysql");
mysql_select_db ("yourdbname")
or exit ("could not select db");
$result = mysql_query ("SELECT * FROM yourtablename
ORDER BY partnumber ASC");
echo "<TABLE BORDER>
<TR>
<TH>Part #</TH>
<TH>MSRP</TH>
<TH>Disc Rate</TH>
<TH>Sale Price</TH>
</TR>
";
while($row = mysql_fetch_array($result)) {
$pn= $row["partnumber"];
$msrp= $row["msrp"];
$disc= $row["discount"];
$salepr= round($msrp * $disc, 2);
echo "<TR>
<TD>$bull</TD>
<TD>$msrp</TD>
<TD>$disc</TD>
<TD>$salepr</TD>
</TR>
";
} //this closes the loop
</TABLE>
?>