Jump to content

[SOLVED] Dealership Database


Recommended Posts

I am wondering if anyone could point me in the right direction.

 

I am looking to build an entire database for use with a used car dealership.

The database will be replacing a current ColdFusion database that is ancient like a dinosaur and was built by a previously hired programmer that left us with 0 support.

 

I know a bit of PHP, I've done database entry and retrieval, but never for this many variables, and I also have never done images.

 

What I need:

 

a) A back-end with a form that allows the dealership to add vehcicles with field for Vehicle, Model, KMs, etc

b) A field/method to upload images to the server and have them associated with the same database file.

c) A way to retrieve all this information and display it in a functional manner

 

I have been googling, reading and repeating the process over and over, but I thought someone here might have a great resource or even a template of some sort for me to view and base my project off of.

 

Thanks in advance, this community is always a great one!

 

Link to comment
Share on other sites

I think a step into the right direction might be to look into Database Normalization: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html

 

unfortunatly I dont know of a project you can base yours off..but sounds like your being proactive...what are your current plans...what concepts have you loooked into ??

Link to comment
Share on other sites

The concepts I'm looking into are mostly simple ones, such as entering data into a database.

I need to do this step-by-step.. but not in one tutorial?

 

I can better explain that by saying that I need to understand every little thing I do. I can't follow a tutorial for making a car database, I'm going to study how to enter data, recall, images.. and then assemble it.

 

Long term I hope to reuse this script for multiple dealerships because I travel between dealerships with my work and they all use different software and may or may not be open to change.

 

Thanks for the link though, it's a really informative one I had not seen before.

Link to comment
Share on other sites

yeah sounds like you migth want to checkout the basic's tutorial on SQL syntax for inserting/updating/deleting data from a database from http://www.w3schools.com/sql/default.asp ....I find that to be a great resource for learning SQL.... after which data normalization would probably be the best way to handle your database..... How good are you with php ?  for tutorials on the more basic concepts phpbuddy.com is great....

 

Cheers!

Link to comment
Share on other sites

Thanks so much mate,

I'll be bookmarking these resources.

I know it's probably a stretch, but I'm going to try and get this completed before the end of the week.. at least the basics anyways.

I'll be back on here when I hit a road block. PHP skills need a refresher, I've only ever done the necessities.

 

Thanks again!

Link to comment
Share on other sites

How hard is it to set the options to organize lists by Name, Price, Model, Make.. etc?

I would like to avoid using different files for everything.

 

The current site uses ColdFusion and has a file (inventory.cfm) that does all the work until a car is selected when carinfo.cfm is loaded. Can PHP organize my tables inside the single php file?

 

Right now I have files such as cars.php, vans.php, trucks.php.. can I avoid this too?

 

I would like to have one inventory.php file if at all possible. So far I have all these files which each grab content from the database and display it based on the type of vehicle it is. I am working on the database data entry forms now.

Link to comment
Share on other sites

gamerzfuse,

 

I highly recommend you STOP coding and step back and PLAN what you are going to do.  While it can be good practice learning something and then coding it, especially for something you're interested in (ex: this database project), you should not skip any essential steps when building an application such as this.

 

Think about what you need, in general.  You have a database.  Cars.  Trucks.. etc.. Different types of data about these vehicles..  You want to view them, sort them, add, delete, modify.  Not to mention images for said vehicles, etc.  Cool.  Are there other things you will want?  Think about the needs of the application... What is essential, what isn't, what would be good to have, what doesn't belong, etc.

 

Draw it out.  Get a piece of paper and sketch out little pictures representing your data and concepts.  (crappy)Example:

 

exampleideas.PNG

 

This is just something to get you thinking about how your application will work/interact.  It could have just 1 page, it could have 10 pages.  It could support only 1 database, or it could support 2-3 databases, etc, etc.  It's all up to you, just plan it out and stick with it.

 

The key thing to take away is to break your ideas into parts (and ideally see them as objects) in order to keep the coding simple.  Hope this helped a bit, good luck.

 

ps> regarding your sorting thing, it is pretty easy to ask mysql to sort for you if your fields are setup appropriately

Link to comment
Share on other sites

Thanks very much for the reply!

I have already had the entire thing planned out because I'm replacing an existing database/application feature for feature.

 

I now have everything in place for the entering data, editing, deleting and viewing.

 

Problem #1:

 

<?php if ($vehicle->absbrakes->Visible) { // absbrakes ?>
<tr<?php echo $vehicle->absbrakes->RowAttributes ?>>
	<td class="ewTableHeader">Absbrakes</td>
	<td<?php echo $vehicle->absbrakes->CellAttributes() ?>>
<div<?php echo $vehicle->absbrakes->ViewAttributes() ?>><?php echo $vehicle->absbrakes->ViewValue ?></div></td>
</tr>
<?php } ?>

 

The above code is the output for:

 

<?php if ($vehicle->absbrakes->Visible) { // absbrakes ?>
<tr<?php echo $vehicle->absbrakes->RowAttributes ?>>
	<td class="ewTableHeader">Absbrakes<span class="ewRequired"> *</span></td>
	<td<?php echo $vehicle->absbrakes->CellAttributes() ?>><span id="el_absbrakes">
<div id="tp_x_absbrakes" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_absbrakes[]" id="x_absbrakes[]" value="{value}"<?php echo $vehicle->absbrakes->EditAttributes() ?>></div>
<div id="dsl_x_absbrakes" repeatcolumn="5">
<?php
$arwrk = $vehicle->absbrakes->EditValue;
if (is_array($arwrk)) {
$armultiwrk= explode(",", strval($vehicle->absbrakes->CurrentValue));
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
	$selwrk = "";
	for ($ari = 0; $ari < count($armultiwrk); $ari++) {
		if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
			$selwrk = " checked=\"checked\"";
			if ($selwrk <> "") $emptywrk = FALSE;
			break;
		}
	}

	// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="checkbox" name="x_absbrakes[]" id="x_absbrakes[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $vehicle->absbrakes->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
}
}
?>
</div>
</span><?php echo $vehicle->absbrakes->CustomMsg ?></td>
</tr>
<?php } ?>

 

I need the output to display as checkboxes also. (Checkboxes that can't be checked or unchecked, but just display the 1 or 0 from database)

 

Currently it just display nothing if the feature is available, and a 0 if the feature is not available.

 

Problem #2 will come in the future, I'm just laying out my vehicle viewing page now.

 

Thanks!

 

Link to comment
Share on other sites

Cool, I wasn't aware how far along you were or your expertise, looks like you've got it going pretty well so far.

 

Currently it just display nothing if the feature is available, and a 0 if the feature is not available.

<input type="checkbox" name="x_absbrakes[]" id="x_absbrakes[]" value="{value}"<?php echo $vehicle->absbrakes->EditAttributes() ?>></div>

I don't know what everything evaluates to here, but if I'm not mistaken value="{value}" may need to be changed?

Also, checkboxes can have the property "checked" and "disabled" in order to show it as selected, and also to allow/disallow changes.

http://www.w3schools.com/HTMLDOM/dom_obj_checkbox.asp

 

If I'm off base, let me know.. It's hard to guess what your code returns.

Link to comment
Share on other sites

Newest problem:

How can I set a variable to echo with a comma after every 3 digits.

 

Ie:

 

<?php if ($vehicles->price->Visible) { // price ?>
	<td<?php echo $vehicles->price->CellAttributes() ?>>
<div<?php echo $vehicles->price->ViewAttributes() ?>>$<?php echo $vehicles->price->ListViewValue() ?>.00</div>
</td>
<?php } ?>

 

Will show a value of $price.00 but I want the price to have a comma as it reaches the thousands.

ie: $5000.00 = $5,000

 

Thanks in advance! My googling has proved fruitless as every result is about displaying commas in php code.

 

 

Link to comment
Share on other sites

Now.. I think that the number_format works perfect.

Is there any way I can use this just when I echo the variable, or do I have to use it when storing it?

 

Can I somehow add

$show_thousands = number_format($vehicles->price->ListViewValue());

 

<?php if ($vehicles->price->Visible) { // price ?>
      <td<?php echo $vehicles->price->CellAttributes() ?>>
<div<?php echo $vehicles->price->ViewAttributes() ?>>$<?php echo $vehicles->price->ListViewValue() ?>.00</div>
</td>
   <?php } ?>

 

 

Worked just as above, just had to add the line AFTER the if statement.

Figured it out for myself. Thanks!

Link to comment
Share on other sites

I'm sorry for all the begginers questions here, but you've been a huge help X and I'm the kind of guy that figures things out once and never forgets them.

I'm trying to add a default value to an input field, I want it to default show the current date.

 

$today = date('m/j/y');   

 

How can I set the default value of the field to $today, if it is already set to:

 

<input type="text" name="x_dateadd" id="x_dateadd" value="<?php echo $vehicles->dateadd->EditValue ?>"<?php echo $vehicles->dateadd->EditAttributes() ?>>

 

<?php if ($vehicles->dateadd->Visible) { // dateadd ?>
<tr<?php echo $vehicles->dateadd->RowAttributes ?>>
	<td class="ewTableHeader">Dateadd<span class="ewRequired"> *</span></td>
	<td<?php echo $vehicles->dateadd->CellAttributes() ?>><span id="el_dateadd">
<input type="text" name="x_dateadd" id="x_dateadd" value="<?php echo $vehicles->dateadd->EditValue ?>"<?php echo $vehicles->dateadd->EditAttributes() ?>>
</span><?php echo $vehicles->dateadd->CustomMsg ?></td>
</tr>
<?php } ?>

 

My other one that has a default value of Gas shows no difference from the other sections of that code, meaning it is getting the variable from the database itself.

Should I be adding something like date('m/j/y') to that field in the database as the default value?

This one I don't want to mess around with, so I'll wait for your expert advice.

Link to comment
Share on other sites

I'm not sure exactly what you mean...

 

If you want to display today's date in case "$vehicles->dateadd->EditValue" is null, then you could use the ternary operator. (is_null can be replaced to whatever your "not exists" value evaulates to)

$today = ( is_null($vehicles->dateadd->EditValue) ) ? date('m/j/y') : $vehicles->dateadd->EditValue;

The format is:

$var = ( condition ) ? value if true : value if false;

 

*Note:  If this is going to be a proper date stored in a mysql "date" type compatible field, you should use (or convert to) the format: Y-m-d , rather than m/j/y.

 

 

Let us know if you intended something different.

Link to comment
Share on other sites

That may be what I want.. the field is a "date" field, but I can change that at anytime, and I feel that a VARCHAR may be more useful as it is only for displaying the date.

 

Essentially I just want the field to come up (when adding new information to the database) as the current date so the data entry individual doesn't have to add the date.

 

Would this null system work for this?

Thanks so much!

Link to comment
Share on other sites

the field is a "date" field, but I can change that at anytime, and I feel that a VARCHAR may be more useful as it is only for displaying the date.
I suggest keeping dates as a date type.  How hard is it to toString a date.. as opposed to convert a string into a date, then try to perform date operations..

 

Essentially I just want the field to come up (when adding new information to the database) as the current date so the data entry individual doesn't have to add the date.
Then just echo $today, where $today = date('Y-m-d'); or whatever date format you choose.
Link to comment
Share on other sites

Ok.. so that makes things very simple, but where do I put the echo?

I tried this earlier, but I'm not sure what it goes under?

 

<?php if ($vehicles->dateadd->Visible) { // dateadd ?>
<tr<?php echo $vehicles->dateadd->RowAttributes ?>>
	<td class="ewTableHeader">Dateadd<span class="ewRequired"> *</span></td>
	<td<?php echo $vehicles->dateadd->CellAttributes() ?>><span id="el_dateadd">
<input type="text" name="x_dateadd" id="x_dateadd" value="<?php echo $vehicles->dateadd->EditValue ?>"<?php echo $vehicles->dateadd->EditAttributes() ?>>
</span><?php echo $vehicles->dateadd->CustomMsg ?></td>
</tr>
<?php } ?>

Link to comment
Share on other sites

value="<?php echo $vehicles->dateadd->EditValue ?>"

 

value="<?php echo $today ?>"

 

Yeah, thanks!

I figured it out shortly before that, but only because I read over your original posts and figured it out.

You've been a huge help!

Only a huge Internet Explorer issue to work out, and one issue with a database call wrecking all my PHP :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.