Help with sql and PHP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Help with sql and PHP

Postby NickD1982 » 21. April 2012 21:01

I need some help. I'm trying to create a small project for a class and I have XAMPP I'm very new to creating databases and I can't seem to get what I want done. Is there someone available with skype possibly to assist me soon? send PM here if your able to. Below is what I have and what i'm trying to do.


I created a database. I created the following tables. It's a car inventory database. 4 types of cars. the columns are indicated from name of car, price, miles, VIN, Color and manual/automatic Those databases I have done.

Here is what I'm trying to achieve.

One more option, where when in the database you can choose from one of four databases created for cars. I believe this is another database?

I want to make a simple user interface (or if XAMPP has a basic one) where, when you go to the site, it will display a message. Please choose from one of the following types of cars. Then there is a drop down. When one of the databases is chosen, they see what is already there for listing. Then there is a option to add a car, and an option to remove a car from the database using the interface.


That is what I need help on. I don't know how to get to that point. I'm very stumped. Having trouble getting classmates to assist me. Any and all help is greatly appreciated. I like to learn what i'm missing.
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby Altrea » 21. April 2012 22:16

Hi NickD1982,

First: If you want to get help from volunteers, you have to be polite. Some sort of greeting and complimentary close don't cost much time. Some sort of request with Please and a question mark would be polite too.

NickD1982 wrote:Is there someone available with skype possibly to assist me soon? send PM here if your able to.

Second: This is a community based board. You can get help to help yourself. Helping you out via Skype don't assist this community here. No other reader here will profit from your solution. Thats a no go at a non-profit community board.

NickD1982 wrote:I created a database. I created the following tables. It's a car inventory database. 4 types of cars. the columns are indicated from name of car, price, miles, VIN, Color and manual/automatic Those databases I have done.

Sorry, i don't understand your explaination. Can you make that more clear?
- How is your database named?
- How is each of the database tables named?
- How is each of their database table columns named?
Much more clear would be a phpmyadmin database structure dump.

NickD1982 wrote:One more option, where when in the database you can choose from one of four databases created for cars. I believe this is another database?

I don't understand that either. Please try to explain things as clear as possible.

NickD1982 wrote:I want to make a simple user interface (or if XAMPP has a basic one) where, when you go to the site, it will display a message. Please choose from one of the following types of cars. Then there is a drop down. When one of the databases is chosen, they see what is already there for listing.

Normally you will not make a new database or database table for each type of car. Similar objects were commonly saved inside the same database table with one extra column for the different property.

XAMPP does have something like an example application which can assist you with that task. Take a look into the CD Collection example in your orange XAMPP Administration page.

NickD1982 wrote:That is what I need help on. I don't know how to get to that point. I'm very stumped. Having trouble getting classmates to assist me.

You need to start somewhere. You need a database, you need a site where you output the database entries, you need a html form to add new entries.
We will not make your homework for you. We can assist you if you have specific issues, but nothing more.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with sql and PHP

Postby NickD1982 » 21. April 2012 22:59

I'm very sorry for my rudeness. Was not intended. I apologies. Allow me to be more specific if I can. I'm taking a database type class. Very frustrating and I've also explained this to my university. But this is the only class that is holding me up. So you can see, my understanding of databases is limited. This was a elective I thought I would enjoy learning.

in myphpadmin I created the following database.

niccar (short for nick and car)

Within that database I created 4 tables with 6 columns each. The tables are listed.

Sedan, Toyota, Ford, Honda within those tables are my columns. Name of car (varchar) 255, VIN (varchar(255, Miles (INT) 6, Price (INT) 6, Color (varchar) 255, and Manual/Automatic (varchar)255.

I have data in each of those tables as examples. Creating the database wasn't that hard of a task. But want I want to do is view it in some sort of web interface so I can click on an add button to add cars into the database based on the columns I have created. A while ago I used a PHP forums on a website. All I did was upload the files, and ran an installer within the web browser itself and it was done and I had my forums. But since this is a database, I like to be able to view the data on a web browser. (I hope I am making sense).

Any help would greatly be appreciated. I do apologies again for coming off rude. I didn't mean it, nor did I see it. Was just frustrated.

When our instructor was teaching the class, we used the Command prompt to create tables, and implement the data. We could use myphpadmin to create the scripts and just paste it in. That is the extent of our class. The book I have been reading (not all of it just the chapters we go over) is. The Definitive Guide to MySQL 5 third edition by Michael Kofler.

Mostly, I just like someone to be able to help me when I get stuck on a step and explain it better. I just want to make this project simple and to the point, with a easy type of user interface. Do I need to install something else to get that user interface to interact with the database itself?
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby Altrea » 22. April 2012 00:09

Hi NickD1982,

Your explaination is much more clear now.

NickD1982 wrote:Do I need to install something else to get that user interface to interact with the database itself?

No, but you will need some knowledge in PHP, HTML and CSS. PHP for all the programming stuff and interaction with the database and HTML/CSS for creating and styling of the table view for the entrys the form to input new data.

Like i said XAMPP does already have an example application. Its functionality includes adding new entrys, delete entrys and view a table of entrys. It uses a mysql database, so that would be an example application which comes very close to your needs.
The sourcecode of that example can be found in C:\xampp\htdocs\xampp\cds.php (assuming you have installed XAMPP in your C: drive).

The easiest way to make it fit with your car inventory would be to change your database. Delete the 4 car tables and create a new table "car" with 8 columns (id, brand, model, vin, miles, price, color, geartype). id has to be an auto increment integer value. Nearly each database table should have such a key column.
brand is the name of the brand (Sedan, Honda, Toyota, etc).

Then you should take a look into the sourcecode of the cd collection and identify the places you have to change to fit your car. Should be enough for lesson one :D
Let me know if something isn't clear or you get in trouble.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with sql and PHP

Postby NickD1982 » 22. April 2012 03:23

I do have knowledge of HTML5 and XHTML and Java... a little lol. I will try and work with it and see if I can get it to work. Thank you Altrea, I'll let you know in the morning what I get.
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby NickD1982 » 22. April 2012 03:30

Doh, I goofed on something. the index.php file in the folder prior, I modified that based on a tutorial I was viewing and i forgot to copy the code that I deleted. Can you provide me that code for the default index.php? I can't get the localhost screen default to view due to my silly error. Thank you.
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby Altrea » 22. April 2012 03:31

Sure :D
Code: Select all
<?php
   if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
      $uri = 'https://';
   } else {
      $uri = 'http://';
   }
   $uri .= $_SERVER['HTTP_HOST'];
   header('Location: '.$uri.'/xampp/');
   exit;
?>
Something is wrong with the XAMPP installation :-(
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with sql and PHP

Postby NickD1982 » 22. April 2012 03:58

Thank you Altrea. Another question though.

You pointed me to the source code for the application. Sorry to be such new at this, but how do I get to the application at hand? learning how to pull it up using the command prompt is one thing, but having the UI, application is nice also. Just like to know how to access it. Or am I missing something? I'd like to see the layout and how it works, then I can try to copy and paste it to my own needs with my own database (Thanks for the tip by the way, one table is much better lol.)
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby Altrea » 22. April 2012 04:16

NickD1982 wrote:I'd like to see the layout and how it works

Well, i have already told you that :D

Step by step
  • Open your browser
  • type in http://localhost/
  • choose your language (if not already done)
    Now you should have the orange XAMPP Administration page in front of you
  • left in the Navigation column you can find a Link "CD Collection" (it is pointing to http://localhost/xampp/cds.php)

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with sql and PHP

Postby NickD1982 » 22. April 2012 04:47

Doh, Now I understand. Thanks!
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby NickD1982 » 22. April 2012 18:43

Okay now I need help to understand coding here. I'm looking at the cds.php file and the coding inside. User states I can modify it for personal use pretty much. I hope I'm right for my own experience.

In the script, I know I have to reference my database niccar by replacing cdcol with niccar

to get the embedding blank spaces to show the "enter data" such as brand, VIN, Miles all associated with my database, I have to make changes? There are 3 in the example listed, but I have more then 3 items. Programming is not what i'm good at. I can barely understand the coding itself. What I want to do is put my database in there and see if the interface works. (NOTE: I backed up all the XAMPP files to restore later so I don't damage my orginal XAMPP installation.)

Can someone help me out. Kind of help me understand where I need to make changes. I suppose I'm ready for my next lesson?

Thank you for assisting me on this.
NickD1982
 
Posts: 7
Joined: 21. April 2012 20:53
Operating System: Win 7

Re: Help with sql and PHP

Postby Altrea » 23. April 2012 05:12

NickD1982 wrote:In the script, I know I have to reference my database niccar by replacing cdcol with niccar

correct.

NickD1982 wrote:to get the embedding blank spaces to show the "enter data" such as brand, VIN, Miles all associated with my database, I have to make changes?

yes

NickD1982 wrote:There are 3 in the example listed, but I have more then 3 items.

It is not important how many items you (will) have in your database. All items are fetched with only one mysql query.
But you first must change the sql query to fetch all of your 8 columns instead of just the three of the example. (~ line 114)
Then you have to change the HTML (markup) to show that 8 columns on the page (~ lines 125-133).

Thats lesson two.

Important thing to know: All Variables which start with $TEXT are just for multilanguage-support. That can be confusing. But each of them can be replaced with normal strings without breaking something.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 138 guests