Jump to content

paruby

Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by paruby

  1. Thank you both for the help. I believe I can get to what I am envisioning from here. Pete
  2. Thank you for the reply mjdamato. ibelieve I have the first part done, not to have the user enter a number of items greater than what is currently available. For the part in question, I looking specifically at the case where the user will enter "3" for the item, the code will immediately run to subtract the inventory from 5 to 3, then they change their mind, and want to order 4, and change the value in the field to 4. The DB already has 2 available, and since it is running as AJAX, my number available is still 5, and allows them to change from 3 to 4.
  3. I have items in my DB as inventory. The table has 2 main fields for this, a total inventory # (per item), and a "remaining" field that will count down as the item is ordered. My problem is keeping track of the "remaining" number. There are two ways on the web page a user can change the # of an item they want, by entering a number in a form field which they can only enter a number up to the current # of items left at the time they load the page, and by using up and down arrows. Each click of the arrow is an addition or deduction of 1 item. In this case, I can keep track of how many are left, because I know it is always +1 or -1. The issue is with the manually entered field. For example, if item1 has 5 left, and a user types in 3, I can easily just subtract 3 from the inventory, and get 2. But, if the user then types in 4 for item1, I do not know that the last value they entered was 3, to get the difference of 1, and subtract 1 more from inventory, nor do I know that when they first started, there were 5 left, and subtract 4 to get 1. This gets even more confusing if there are 2 users trying to get the same item... This must be a common thing, but again, I cannot get it figured out... In advance, thank you to all who have replied and helped on my other posts lately. These questions all revolve around the same site I am building, and have maybe bit off more than I can chew at a reasonable pace... Pete
  4. OK, figured it out. I am already making a call to my database to get item details, and the starting value of the field, so I just added another variable for the max value, and set that along to my JS/Ajax call, and it f the value of the field is greater than my max value, I change the field value back to the max, and send an alert msgbox to the screen.
  5. I have form fields for the # of items of an object, ie. a shopping cart. I want to be able to restrict a user to only enter a specific number range for the quantity of an item in the form field box. I am not aware of a form field variable such as "maxvalue", but can I do it some other way? I want to get the max number out of the database. Not sure if this helps, but I am already using Ajax to set the form field values in database tables, but cannot seem to set a max value. If this is not clear enough, let me know. Thanks Pete
  6. I have a table of data I want to cycle through, that includes a field that can be 1 of 4 values (an id from a 2nd table - named "locationID"). I want to query the first table order by locationID. Then for each distinct value of locationID, do specific work on those rows (could be more than 1 row returned for each locationID). My initial thought is since I know how many different locationID's there are (4), I an just do 4 different queries, 1 for each locationID (WHERE locationID = 1 , 2, etc), and do the work on each, but this does not sound clean or fast. My next thought was to do one query, get all the rows - ORDER BY locationID, then work on each distinct value of locationID - but that would possibly be a subquery... Any thoughts on the best way to do this? The work I do on each distinct locationID set is the same except for setting values. Thanks Pete
  7. Gizmola, Thanks again for your help so far. Here is what I get when i try to print out the array (print_r($arr) :: Array ( [12] => Beverages [15] => Soda ) Array ( [12] => Beverages [15] => Soda [16] => Milk ) Array ( [12] => Beverages [15] => Soda [16] => Milk ) Array ( [12] => Beverages [15] => Soda [16] => Milk [13] => Frozen Foods [14] => Ice Cream ) Array ( [12] => Beverages [15] => Soda [16] => Milk [13] => Frozen Foods [14] => Ice Cream [17] => Popsicles ) Array ( [12] => Beverages [15] => Soda [16] => Milk [13] => Frozen Foods [14] => Ice Cream [17] => Popsicles ) Array ( [12] => Beverages [15] => Soda [16] => Milk [13] => Frozen Foods [14] => Ice Cream [17] => Popsicles ) Can you tell me how to just return the last set of array?
  8. Thank you gizmola. I will test it in a bit. My question now is, what does the "&" do before the variable name (&$arr)? I have seen it before, and tried googling it, but have not found it...?
  9. Hope this helps others - As a workaround, I just added the listbox code directly into my function, like this :: echo "<option value=\"$thisCatID\">$value</option>\n"; Then, when calling my function, I wrapped the <select> nodes, ie :: echo "<select name='catTree' size='10'>\n"; createCatTree(); echo "</select>"; But, I still would like to be able to hold the data in an array, so I can use it in different ways as needed. Thanks, Pete
  10. I have a database table with categories and subcategories, with the structure of :: categoryid, categoryname, parentid I have found numerous examples of printing out a tree structure of the table, and it works, but I would like to get all the data into an array, ultimately to print the array to a listbox to select from. The array structure would be categoryid => categoryname. The basic query I have now is as follows :: function createCatTree($thisParentCatID=0,$depth=0) { $catIDQ = mysql_query("SELECT * from category WHERE parentcatid = $thisParentCatID;"); while ( $catIDQRow = mysql_fetch_array($catIDQ) ) { $thisCatName = $catIDQRow['categoryname']; $thisCatID = $catIDQRow['categoryid']; for($i = 0; $i < $depth; $i++) $spcstr.= " "; // create spaces to mimic a tree structure $value = $spcstr.$thisCatName; // add spaces echo $value; createCatTree($thisCatID,$depth+1); } } I was hoping to send the categoryid and categoryname to an array, like $arr[$thisCatID] = $value; then change my function call to be createCatTree($thisCatID,$depth+1,$arr); to send the array as a variable back to the function to hold the data going forward. Also, I added a section at the top of the function to see if the array needed to be initialized, like if ($arr == "") { $arr = array(); } but this does not work. Is there any way to use this basic recursive code and save all the data to an array to be worked on at a later time?
  11. Thank you both for the suggestions. I actually found "strip_tags()" while looking at the first 2 suggestions. I am using that, as it seems "cleaner"... If not for your suggestions, i may not have found it...! Pete
  12. i have an admin page that lists all the rows from a table. One of the fields is generated using FCKEditor, so the field has HTML Code in it. I would like to only show the first 100 or so chars of the field, but if the 100 chars ends in the middle of HTML code, specifically in this case <a href>, it cuts off, and creates "havoc" in my page. Is there a way to avoid this by seeing that the 100 char is in the middle of an <a href> tag (or any tag for that matter? Here is what the generated html can look like :: <td class="tdresults">We are very excited to offer three great events at the <a href="http://www.mylongwebsite.c</td> <td class="tdresults">next field data</td> Thank you in advance. Pete
  13. Not sure if this is the correct forum, but I have a few FCKEditor questions that I have not found on the CKEditor site, and hoping someone here has any answers... I have 2 questions/issues - 1. relative links - I have a site like http://www.mydomain.com/myadmin/adminpage.php. In this page I have FCKEditor 2.6.5 that I can enter text for an article to place on a page in the root of the site, http://www.mydomain.com/, along with links to internal pages. When I create the link in FCKEditor, I click the "link" icon, and use the Protocol of "Other" and type in "test.html" for the URL. But my link then comes out as " http://www.mydomain.com/myadmin/test.html", when I really want "http://www.mydomain.com/test.html". I want to make the link relative to the basehref setting in the FCKConfig that is set to "http://www.mydomain.com", OR, just create the link as relative, the way I type it into FCKEditor. Is this possible? 2. Is it possible for FCKEditor, when pasting text into the textarea, have it ignore any predefined HTML code? I get a lot of info in Outlook, and if I copy it directly from there, I get all the MS crap formatting. I want to have it stripped out, as if i had copied the text from Notepad. I have no problem putting it into Notepad and then into FCK, but I am afraid regular users will not know how to do this... Thank You. Pete
  14. I really need to Google first! Sorry... Here is the link I am using... http://www.cstruter.com/blog/115
  15. Hello - I am trying to do the following, which I have seen on many web pages, but not sure if there is an easy way to do it... I have 2 list boxes, side by side with buttons in between, one pointing left, one pointing right. By clicking the appropriate arrow, the info selected in either box is moved over to the other - List 1 List 2 |---------| |---------| | | > | | | | | | | | < | | ----------- ----------- I can see doing it w/ PHP & XML, and although I have not coded it all, I can see it being very bulky, and wondering if there is something already written... Thanx! Pete
  16. Oh, I messed up, sorry everyone. The key and value pairs are NOT from the same MySQL call, but separate values gotten from 2 separate DB calls. And the 2 tables are not directly related, but related between a 3rd table (not sure if that matters). Let me give the real case scenario - I have items with prices, and the items may or may not be taxable, and there are multiple tax %. So $key represents the ID of the tax amount table, and $value is the price of the item. So I want to add up all the items w/ taxID = 1, then apply the tax %, and add up all items w/ taxID = 2, and then apply that tax %
  17. I have data that is based on a key->value scenario. My hope is this - add up all the "values" that have the same "key". I have code like :: $result = mysql_query("SELECT * FROM table) while ($resultsRow = mysql_fetch_array($results)) { $key = $resultsRow['typeid']; $value = $resultsRow['value']; $pairs["$value"] = $key; } foreach($pairs AS $value => $key) { .... add each $value together that have the same $key. So if I had something like array(1->2, 1->5, 1->8, 2->5, 2->7), I could arrive at array(1->15, 2->12). I saw "array_sum", but it isn't quite what I am looking for... Is this at all possible? Thanx! Pete
  18. Thanx kumarkiranm . That is exactly what I am looking for. And it's a great place to start w/ AJAX. I have been hesitant to get into it, but looks very easy here! Pete
  19. i am trying to create a shopping cart system, like peapod.com, or netgrocer.com. I noticed 2 things that I would like to replicate :: 1. When you change the quantity, the page does not refresh, and 2. the shopping cart on the right frame does update, and refresh. I think I have found how the quantity changes w/out a page refresh, with javascript. but, I can not determine how to (at the same time) update the DB with the new quantity to update the shopping cart. Since I can not call PHP from javascript, I was hoping I could put code on the "onChange" event of the quantity field to only update the DB and only refresh the shopping cart data, again, without having the main page refresh. If you see my code at http://lpbj.net/eshop/, you will see I tried to put a basic alert messagebox on the "onChange" event, but it doesn't always fire (event tried changing the focus)... Anyway, hopefully I can get some help/ ideas on the best way to do this. As a side note, I have seen examples putting all the quantities/products into an array, but my concern is that the user will leave before checking out and saving the data to the DB, and i would like the shopping cart to be dynamically changing... Pete
  20. OK. I think I got it... Posting in case anyone else is interested... First, I had to get the values that were to be "SELECTED" - this is in addition to the existing query to get the full list :: select * from Table where ...; while rows { $thisAthID = $GetRow['id']; $thisraID = $GetRow['name']; $athIDPairs["$thisraID"] = $thisAthID; } Then I had to change the function as follows :: function createListBox($identifier, $pairs, $helptext="", $multiple="", $key="", $numitems="") { if ($numitems == "") { $numitems = "1"; } $listbox = "<select name=\"$identifier\" $multiple size=\"$numitems\">\n"; if ($helptext != "") { $listbox .= " <option value=\"99999\">$helptext</option>\n"; } foreach($pairs AS $value => $name) { $selectOpt = ""; if (key != "") { foreach($key as $thisraID => $thisAthID) { if ($value == $thisAthID) { $selectOpt = " SELECTED"; continue; } } } $listbox .= " <option value=\"$value\"$selectOpt>$name</option>\n"; } $listbox .= "</select>\n"; return $listbox; } It basically checks to see if the ID of the list item matches any of the Selected item ID's. If it does, add the "selected' keyword to the code...
  21. Hello - I found the following code to create combo and list boxes, and it works great :: function createComboBox($identifier, $pairs, $helptext="", $multiple="", $key="", $numitems="") { if ($numitems == "") { $numitems = "1"; } $listbox = "<select name=\"$identifier\" $multiple size=\"$numitems\">\n"; if ($helptext != "") { $listbox .= " <option value=\"99999\">$helptext</option>\n"; } foreach($pairs AS $value => $name) { if ($value == $key) { $listbox .= " <option value=\"$value\" SELECTED>$name</option>\n"; } else $listbox .= " <option value=\"$value\">$name</option>\n"; } $listbox .= "</select>\n"; return $listbox; } If it makes sense, it only allows for one item to be selected. I am using the following "code" to to send to the function :: select * from table; while rows { $value = $GetRow['id']; $name = $GetRow['name']; $pairs["$value"] = $name; } echo createComboBox("cboathlete[]", $pairs, "", "MULTIPLE", "", "5"); I am not versed enough to figure out how to change the function to just send (for instance) a comma delimited list of items to be selected. i would like to send a list of id's that should be selected in the listbox. I am hoping it is pretty straight forward, and only need to change around the "if ($value == $key) " piece of the fuction. Thanx! Pete
  22. paruby

    Confirm Images?

    OK, Not sure if I am even in the right forum for this question, so if I need to be moved, please do... What are those images called that are words that you type what they say into another form field to validate the form submission? And, can someone point me to where I can learn about incorporating them into a page. I have a contact from that's getting hit w/ a lot of spam, hoping this will stop it... Thanx! Pete
  23. I have a list of data, race results - called Events. It includes race name, participating athlete names, and race distance. I have a page currently that has a spot at the top of the page to enter a new event, which works well. Below that, I have a list of each existing event, each with an "edit" and "delete" link. I am hoping this page can be used by the web site owner (not me - currently I am designing and maintaining this info), so I would like it as easy as possible. My dilemma is :: 1. do I have the "New Event" fields on this page, or do I have a link to a separate page to add a new row 2. When I edit an existing item, do I a. put the data into the fields currently there for a new row, and then use them to modify the existing row or b. link to a separate page to edit the info? I am looking for an overall nice even flow of pages, etc, with less confusion for the end user. Thanx! Pete
  24. I know PHP, and I know Flash (a little...). Can anyone point me to a few basic tutorials on how to incorporate PHP and a DB backend into a Flash object? Thanx! Pete
  25. I have the following table on my page :: <table border="1" cellpadding="3" cellspacing="3" bordercolor="#808080" width="649"> <tr> <td width"200" class="tdhead">Header Text</td> <td width"440" class="tdhead">Header Text 2</td> </tr> <tr> <td width"200" class="tdresult">Text</td> <td width"440" class="tdresult">Text 2</td> </tr> </table> The corresponding CSS I have so far is :: .tdhead { font-family: arial, helvetica, sans-serif; font-size: 13px; color: #FFFFFF; font-weight: bold; background-color: #000000; } .tdresult { font-family: arial, helvetica, sans-serif; font-size: 13px; color: #000000; } I would like to get away from the <table> code fully if possible... Can someone post what the corresponding full CSS would be, without the <table> HTML? Thanx! paruby
×
×
  • 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.