
gamerzfuse
Members-
Posts
116 -
Joined
-
Last visited
Never
Everything posted by gamerzfuse
-
Displaying Values From Database With Exception/Within Range
gamerzfuse replied to gamerzfuse's topic in PHP Coding Help
Thanks so much mate! I'll be back if it doesn't, but they both look very logical. -
[SOLVED] Checkbox Displaying from Database
gamerzfuse replied to gamerzfuse's topic in PHP Coding Help
Finally figured this one out. Almost solved, one last question: Any way to make a disabled checkbox less.. grey? It's very difficult to see a disable checkbox. -
I need to adapt the following code (which displays all vehicles with the same model as the displayed vehicle) for two separate purposes: a) Exclude the vehicle that is currently being viewed. The Key value is their stock number, I would like to somehow do SELECT * FROM vehicles WHERE model=$model "EXCLUDING stock=$stock" b) I need to use this code to display a SEPARATE box that shows vehicles with prices within $2000 of the currently displayed vehicle. ie: SELECT * FROM vehicles WHERE price="BETWEEN ($price - 2000) ($price + 2000)" <?php //Make first query to database $query = "SELECT * FROM vehicles"; $result = mysql_query($query) or die ("Couldn’t execute query."); //Set Variables $vehiclemodel = $vehicles->model->ViewValue; $show_price = number_format($vehicles->price->ViewValue); $query = "SELECT * FROM vehicles WHERE model='$vehiclemodel'"; $result = mysql_query($query) or die ("Couldn't execute query."); // Display results in a table echo "<tr><td colspan='5'></td></tr>"; while ($row = mysql_fetch_array($result)) { extract($row); //Table Contents echo "<tr class='dataright'>\n <td colspan='5' class='dataleft'><a href='view.php?stock=$stock'>$year $model</a></td>\n <td>$odometer km </td>\n <td align='right'>$$show_price.00</td>\n </tr>\n"; echo "<tr><td colspan='3'></td></tr>\n"; } ?> Any help would be much appreciated as I am very close to finalizing this project, I'm a bit of a new comer to PHP but I'm learning quick. Thanks!
-
Well.. I'm going to start Googling Ajax calculator and such. If I can find a generator that saves me time, I will generate a calculator and then clone it so I know how it all works.
-
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 } ?>
-
Got it. Thanks! Looking into all this soon. Never used Ajax before, but if you can enlighten me I would be very excited to learn!
-
I would love to use PHP as I am quickly becoming much better at it and the possibilities of PHP are endless from what I have seen. I'm looking into these math functions and they should work. I'll probably have a couple <input> fields that need to be multiplied, shouldn't require anything but multiplication.. although the actual Amortization formula is much more complex and requires ^ (to the power of) values also. I imagine I will easily find the answer while googling in the morning, but I assume there is a way to set input forms to $variables without much hassle? Thanks for all your help, this is the best learning experience I've had in coding since I read HTML For Dummies front to back
-
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!
-
I got it authorized by them to skip that and just program a calculator. Is it easiest to code a calculator in PHP or in Javascript or what? I just need a simple one with Months, Interest Rate, Downpayment, etc.
-
I'm still trying to figure that out. I'm going to go into the dealership and just see if I can get someone else to do the formulas for me. My headache is too much already. Then I guess I can just manually calculate each one?
-
[SOLVED] Checkbox Displaying from Database
gamerzfuse replied to gamerzfuse's topic in PHP Coding Help
I read the tutorial, but it all seems complicated to me. I have already setup a form to enter a 1 if the box is checked and a 0 if the box is unchecked. Is there no simple line of code to then retrieve this? Something like: <?php $heatedseats = $vehicles->heatedseats->ViewValue if $heatedseats == "1" { $checked = ? 'checked="checked"'; } ?> ? Thanks for you help! -
[SOLVED] Checkbox Displaying from Database
gamerzfuse replied to gamerzfuse's topic in PHP Coding Help
I just don't understand this line: $yourValueFromDb = 1; How does this value work, or how do I ask the database if the value =1? -
<input type="checkbox" id="heatedseats" name= "heatedseats" disabled="disabled" value= "<?php $vehicles->heatedseats->ViewValue ?>"/> This is essentially what I want to do (but this checkbox does not return the value from the database) I have a databast called vehicles, a field called heatedseats and I want to take the tinyint value from that field (1 or 0) and display it as a checkbox, checked or unchecked, but also disable to checking. This is for a features list. Thanks!
-
I know there are many calculators out there that calculate monthly payments, etc.. but I just need a simple one that calculates (in a table) the Monthly payments for a vehicle over certain months at different money down at a set interest amount. Example: If I knew where to start that would be super helpful. I am more than willing to build it myself, but I don't even understand the payments myself (not the best Accountant here) Any ideas?
-
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.
-
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!
-
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.
-
All the code will exceed the character limits of this post. I think it may be the fact that I removed include: header.php Here's the code from Header.php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Goodwill's Used Cars - Aylmer, St. Thomas, Tilsonburg Ontario</title> <?php if (@$gsExport == "") { ?> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/container/assets/skins/sam/container.css"> <?php } ?> <?php if (@$gsExport == "" || @$gsExport == "print") { ?> <link rel="stylesheet" type="text/css" href="vehicles.css"> <?php } ?> </head> <body class="yui-skin-sam"> <?php if (@$gsExport == "") { ?> <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/container/container-min.js"></script> <script type="text/javascript"> <!-- var EW_DATE_SEPARATOR = "/"; if (EW_DATE_SEPARATOR == "") EW_DATE_SEPARATOR = "/"; // Default date separator var EW_UPLOAD_ALLOWED_FILE_EXT = "gif,jpg,jpeg,bmp,png,doc,xls,pdf,zip"; // Allowed upload file extension var EW_FIELD_SEP = ", "; // Default field separator // Ajax settings var EW_RECORD_DELIMITER = "\r"; var EW_FIELD_DELIMITER = "|"; var EW_LOOKUP_FILE_NAME = "ewlookup6.php"; // lookup file name //var EW_ADD_OPTION_FILE_NAME = ""; // add option file name var EW_BUTTON_SUBMIT_TEXT = " Add "; var EW_BUTTON_CANCEL_TEXT = " Cancel "; //--> </script> <script type="text/javascript" src="js/ewp6.js"></script> <script type="text/javascript" src="js/userfn6.js"></script> <script language="JavaScript" type="text/javascript"> <!-- // Write your client script here, no need to add script tags. // To include another .js script, use: // ew_ClientScriptInclude("my_javascript.js"); //--> </script> <div class="ewLayout"> <!-- header (begin) --> <div class="ewHeaderRow"><center><img src="phpmkrlogo6.png" alt="" border="0"></center></div> <!-- header (end) --> <!-- content (begin) --> <table cellspacing="0" class="ewContentTable"> <tr> <td class="ewMenuColumn"> <!-- left column (begin) --> <?php include "ewmenu.php" ?> <!-- left column (end) --> </td> <td class="ewContentColumn"> <!-- right column (begin) --> <p class="phpmaker"><b></b></p> <?php } ?> That seems to be the only thing I removed, besides the $security stuff. The following is the beginnning section of the invent.php file that has the problem: <?php session_start(); // Initialize session data ob_start(); // Turn on output buffering ?> <?php include "ewcfg6.php" ?> <?php include "ewmysql6.php" ?> <?php include "phpfn6.php" ?> <?php include "vehicleinfo.php" ?> <?php include "userfn6.php" ?> <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 ?> <?php // Define page object $vehicle_list = new cvehicle_list(); $Page =& $vehicle_list; // Page main processing $vehicle_list->Page_Main(); ?> <?php if ($vehicle->Export == "") { ?> <script type="text/javascript"> <!-- // Create page object var vehicle_list = new ew_Page("vehicle_list"); // page properties vehicle_list.PageID = "list"; // page ID var EW_PAGE_ID = vehicle_list.PageID; // for backward compatibility // extend page with Form_CustomValidate function vehicle_list.Form_CustomValidate = function(fobj) { // DO NOT CHANGE THIS LINE! // Your custom validation code here, return false if invalid. return true; } <?php if (EW_CLIENT_VALIDATE) { ?> vehicle_list.ValidateRequired = true; // uses JavaScript validation <?php } else { ?> vehicle_list.ValidateRequired = false; // no JavaScript validation <?php } ?> //--> </script> <script language="JavaScript" type="text/javascript"> <!-- // Write your client script here, no need to add script tags. // To include another .js script, use: // ew_ClientScriptInclude("my_javascript.js"); //--> </script> <?php } ?> <?php if ($vehicle->Export == "") { ?> <?php } ?> <?php $bSelectLimit = ($vehicle->Export == "" && $vehicle->SelectLimit); if (!$bSelectLimit) $rs = $vehicle_list->LoadRecordset(); $vehicle_list->lTotalRecs = ($bSelectLimit) ? $vehicle->SelectRecordCount() : $rs->RecordCount(); $vehicle_list->lStartRec = 1; if ($vehicle_list->lDisplayRecs <= 0) // Display all records $vehicle_list->lDisplayRecs = $vehicle_list->lTotalRecs; if (!($vehicle->ExportAll && $vehicle->Export <> "")) $vehicle_list->SetUpStartRec(); // Set up start record position if ($bSelectLimit) $rs = $vehicle_list->LoadRecordset($vehicle_list->lStartRec-1, $vehicle_list->lDisplayRecs); ?> I'm going to try rebuilding the site from scratch with a new database table and different values anyways, but I wanted to use this same site template..
-
That will be of alot of assisstance. I did not realize they could be locked from changing. Thanks alot for your help, I'll probably be back with the next issue as it arises.
-
I DID remove this code: if ($Security->IsLoggedIn()) { $vehicle_list->lOptionCnt++; // view } if ($Security->IsLoggedIn()) { $vehicle_list->lOptionCnt++; // edit } if ($Security->IsLoggedIn()) { $vehicle_list->lOptionCnt++; // copy } if ($Security->IsLoggedIn()) { $vehicle_list->lOptionCnt++; // Delete } and <?php if ($Security->IsLoggedIn()) { ?> <td style="white-space: nowrap;"> </td> <?php } ?> <?php if ($Security->IsLoggedIn()) { ?> <td style="white-space: nowrap;"> </td> <?php } ?> <?php if ($Security->IsLoggedIn()) { ?> <td style="white-space: nowrap;"> </td> <?php } ?> <?php if ($Security->IsLoggedIn()) { ?> <td style="white-space: nowrap;"> </td> <?php } ?> On a whim, since it makes the pages publicly viewable, sinve the $security variable is related to being logged in. Could this have changed anything? Otherwise I'm back at stage one and will have to rebuild my page again.. hoping not to miss it this time.
-
I have 0 experience with Javascript. I haven't tried doing anything with it, but I'll go back and compare the two files and check the javascript again. If you could tell me how to debug, that would be stellar. Craig Hooghiem Working URL : http://www.craighooghiem.com/goodwills/demo/inventory.php
-
If I click a header, nothing happens. They give me a clickable cursor, but the click has no results. It works on another file which is almost identical, I just took the content from that file and put it into a table previously designed for the new file. Thanks EDIT: For further information: http://craighooghiem.com/goodwills/demo/invent.php?order=price&ordertype=DESC Does work and sorts the price column by DESC. http://craighooghiem.com/goodwills/demo/invent.php It just doesn't seem to work.
-
I am using the following code in multiple files to sort my tables: <?php if ($vehicle->status->Visible) { // status ?> <?php if ($vehicle->SortUrl($vehicle->status) == "") { ?> <td>Status</td> <?php } else { ?> <td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $vehicle->SortUrl($vehicle->status) ?>',1);"> <table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Status</td><td style="width: 10px;"><?php if ($vehicle->status->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($vehicle->status->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table> </td> <?php } ?> <?php } ?> In one file (and one file only) the sort does not work. That code is applied to every <td> cell it needs to be, but it just doesn't work. Can someone point me in the right direction as to where I would look to find the problem. I used Windows Grep and Notepad++ to do comparisons and searches for related functions, but the comparison only showed that I removed one section about Security (making this publicly viewable without logging in) Any guidance would be much appreciated as I am still learning. Thanks!
-
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!
-
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.