Jump to content

bulrush

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by bulrush

  1. I spoke too soon. Sometimes $newchkbrandarr has the correct values, sometimes not. Let's say I start with chkBrand[] boxes 0, 1, and 4 checked. I click cmdSave to start my save routine in the same php file. I created my own routine to print an array, called crPrintarr. Here's what $newchkbrandarr starts off as: pos 0=1 pos 1=1 pos 2=0 pos 3=0 pos 4=1 These values are all correct. Now if I check the box for chkBrand number 7, I get these values in $newchkbrandarr: pos 0=1 pos 1=1 pos 2=0 pos 3=0 pos 4=1 Noticed that positions 5, 6, and 7 don't even appear in the array! Pos 7 should be 1 (indicating the checkbox chkBrand was checked). Here is my code at the beginning of where cmdSave starts: else if (isset($_POST['cmdSave'])) //Try to save items first. { $partidvar=trim($_POST['txtPartid']); $modelnumvar=trim(crProcmodelnum($_POST['txtModelnum'])); $modelnumvar=strtoupper($modelnumvar); $_SESSION['modelnum']=$modelnumvar; //Save for form display. $modelnumcatvar=trim(crProcprodname($_POST['txtModelnumcat'])); $newpartvar=$_POST['chkNewpart']; //from checkbox to mark part as NEW $prodcatvar=trim($_POST['cbxProdcat']); $prodnamevar=trim(crProcprodname($_POST['txtProdname'])); $prodsubnamevar=trim(crProcprodname($_POST['txtProdsubname'])); $footnotevar=$_POST['chkFootnote']+0; $newchkbrandarr=$_POST['chkBrand']; //Checkbox for each brand. $oldchkbrandarr=$_SESSION['oldchkbrandarr']; //Checkboxes before user changed them. $olddata=$_SESSION['olddata']; //Non-brand Fields strung together. $brandlist=$_SESSION['brandlist']; //List of brands displayed. crPrintarr('chkBrand raw',$_POST['chkBrand']); //DEBUG //Turn nulls in checkboxes to zeros. $cnt=count($newchkbrandarr); for ($j=0; $j<$cnt; $j++) { $newchkbrandarr[$j]=$newchkbrandarr[$j]+0; } //for j $newdata=$partidvar.$modelnumvar.$prodcatvar.$prodnamevar. $prodsubnamevar.$newpartvar.$modelnumcatvar.$footnotevar.$modelnumcatvar; $prodcatvar=($prodcatvar); $prodnamevar=crTitlecase($prodnamevar); $prodsubnamevar=crTitlecase($prodsubnamevar); //Make sure that at least one brand is checked. $cnt=count($newchkbrandarr); crPrintarr('newchkbrandarr',$newchkbrandarr); //DEBUG, params are header to display, and array var $s='Elements in newchkbrandarr cnt='.$cnt; $s.=', count brandlist='.count($brandlist); crDebug($s); //DEBUG $cnt2=0; $cnt=count($newchkbrandarr); //Find number of elements. for ($j=0; $j<$cnt; $j++) { $cnt2=$cnt2+$newchkbrandarr[$j]+0; //$s='arrpos '.$j.': newchkbrandarr='.($newchkbrandarr[$j]+0).', cnt2='.$cnt2; //crDebug($s); //DEBUG } # for j if ($cnt2==0) { $msg='ERROR: at least one brand should be checked. Please choose one. '; $msg.='cnt2='.$cnt2; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$msg,true); } And here is crPrintarr: function crPrintarr($hdr,$arr,$lend='<br/>') /* Print an array to the screen. $hdr=info about array we are displaying $arr=array $lend=line ending */ { $cnt=count($arr); $s='crPrintarr: '.$hdr.'<br/>'; for ($i=0; $i<$cnt; $i++) { $s.='--pos '.$i.'='.$arr[$i].'<br/>'; } //for i crDebug($s); return; }
  2. Ok. Things seem to be working now. My app has its own login and user system. The only thing I did different was I logged off last night, and logged into my app this morning, and the variable $newchkbrandarr appears to be storing the values correctly and passing them to the cmdSave routine in the same php file. I was using IE 8.0. I wonder if it's a bug with IE 8.0. Yesterday I did close all my IE windows, then restart them but I never logged out of my app. When I went back to my app's page, I was still logged into my app. Anyway, $newchkbrandarr is an array that is supposed to reflect the checkmarks stored in chkBrand[], so I can tell if I need to add a new brand to a model (a checkmark was added) or delete a brand from a model (checkmark was unchecked). It wasn't working yesterday, now it is. Thanks!
  3. Sorry I didn't show you that, but at the bottom of the WHILE loop that creates the checkboxes, the $x does get incremented for each row, and each checkbox is in a different array position, going from chkBrand[0] to chkBrand[8]. Here is a partial <FORM> showing how the chkBrand[] is numered. <form action="/toolbox/training/masttest/editpart.php?" method="post"><hr/>Commands: <input type="submit" name="cmdSave" value="Save" title="Save all changes on this screen" /> <hr/><b>Check one or more brands: (Do bullet delete, reorder before doing pricing screen)</b> <table border=1 style="border: 2px solid red;border-collapse:collapse"> <tr valign="bottom"><th>Check box<br/>to enable brand<th>Enable brand?<th>Brand pricing<th>Brand bullets<th>Copy bullets from another brand<th>Override<br/>product name</tr> <tr><td><input type="text" value="brand1" id="txtBrand[]" name="txtBrand[]" size="20" readonly class="mydisabled" /><td align="center"><input type="checkbox" name="chkBrand[0]" id="chkBrand[0]" value="1" checked="checked" /><td>Edit pricing<td><a href="editbullets.php?partid=23280&brand=brand1&model=abc100&prodcat=aaChuckProdcat">Edit bullets (0)</a><td> <td></tr> <tr><td><input type="text" value="brand2" id="txtBrand[]" name="txtBrand[]" size="20" readonly class="mydisabled" /><td align="center"><input type="checkbox" name="chkBrand[1]" id="chkBrand[1]" value="1" /><td><td><td> <td></tr> <tr><td><input type="text" value="brand3" id="txtBrand[]" name="txtBrand[]" size="20" readonly class="mydisabled" /><td align="center"><input type="checkbox" name="chkBrand[2]" id="chkBrand[2]" value="1" /><td><td><td> <td></tr> <tr><td><input type="text" value="brand4" id="txtBrand[]" name="txtBrand[]" size="20" readonly class="mydisabled" /><td align="center"><input type="checkbox" name="chkBrand[3]" id="chkBrand[3]" value="1" /><td><td><td> <td></tr> </table> </form>
  4. Problem: my checkbox array chkBrand[] is not saving data when I click the save button called cmdSave. Each checkbox specifies a brand connected to a model number. Multiple brands can be connected to each model number. (Don't ask, it's what the customer wants.) So, if I check the checkbox in row 0 and row 3, only row 0 shows up. If I check the boxes in row 0, 1, 5, only rows 0, 1 show up in chkBrand and $newchkbrandarr. First, my routine to see which button is checked is at the top of the php file. Here it is. else if (isset($_POST['cmdSave'])) //Try to save items first. { $newchkbrandarr=$_POST['chkBrand']; //Checkbox for each brand. $oldchkbrandarr=$_SESSION['oldchkbrandarr']; $olddata=$_SESSION['olddata']; //Non-brand Fields strung together. $brandlist=$_SESSION['brandlist']; //List of brands displayed. crPrintarr('chkBrand raw',$_POST['chkBrand']); //DEBUG. Prints array to screen. //===At this point chkBrand[] contains: 1 //Turn nulls in checkboxes to zeros. $cnt=count($newchkbrandarr); for ($j=0; $j<$cnt; $j++) { $newchkbrandarr[$j]=$newchkbrandarr[$j]+0; } //for j //Make sure that at least one brand is checked. $cnt=count($newchkbrandarr); crPrintarr('newchkbrandarr',$newchkbrandarr); //DEBUG //===At this point, $newchkbrandarr contains: 1, 0 $s='Elements in newchkbrandarr cnt='.$cnt; $s.=', count brandlist='.count($brandlist); crDebug($s); //DEBUG $cnt2=0; $cnt=count($newchkbrandarr); //Find number of elements. for ($j=0; $j<$cnt; $j++) { $cnt2=$cnt2+$newchkbrandarr[$j]+0; //$s='arrpos '.$j.': newchkbrandarr='.($newchkbrandarr[$j]+0).', cnt2='.$cnt2; //crDebug($s); //DEBUG } # for j Here is my code to construct the array of checkboxes, one per table row. Each checkbox has its array position explicitly defined as $x. $x starts at zero, and is incremented by 1 for each table row (each check box). $x=0; while ($row = mysqli_fetch_array($result)) { $br=trim($row['brand']); //Brand name to display $brandvar=$br; $brandlist[]=$br; //Save every found brand for later. //First find if brand is checked on table "brands". $query2 = "SELECT brand ". "FROM brands ". "WHERE ". "(partid=".$partidvar.") ". "AND (brand='".$br."') ". "ORDER BY brand ". ";"; $cntchk=crqryCount($query2,false); //If $cntchk>0 then brand is checked. //$s="Is brand stored already? <br/>$query2"; //crDebug($s); //DEBUG $query2 = "SELECT brand ". "FROM zzbrands ". "WHERE (brand='".$br."') ". "AND (prodnameoverride=1) ". "ORDER BY brand ". ";"; $override=crqryCount($query2,false); //Can this brand override product name? $s="\n"; $s.='<tr><td>'. '<input type="text" value="'.$br.'" id="txtBrand[]" name="txtBrand[]" '. 'size="20" readonly class="mydisabled" />'; $s.='<td align="center">'; $s.='<input type="checkbox" name="chkBrand['.$x.']" '. 'id="chkBrand['.$x.']" value="1" '; if ($cntchk>0) { $s.='checked="checked" '; $oldchkbrandarr[$x]=1; } else { $oldchkbrandarr[$x]=0; } $s.='/>'; Any ideas what I might be missing?
  5. Thanks. And when the combo box and page is done loading, and the user can click on the combo box, how do I turn off the hourglass and change it to a regular cursor?
  6. I don't know Jquery or Javascript. Is there a way to do it with generic Javascript?
  7. Thanks! I'll try it. ... It worked! I couldn't find that syntax in any manual.
  8. There is a link near the top of the screen "Show new replies to your posts" that shows all threads I have posted in, including ones I have created and ones I haven't, if there are new posts in that thread. I don't want this. I want to see all threads I have created whether they have new posts or not. So I tried to use the search function. When I search for my username, with a word of "the" I get an error that I didn't enter any search terms. If I search for a word "*" then I get an error that each word must be at least 2 characters long. So even the Search function cannot do what I want. Can we have a link up by my username that shows all threads that I have created, whether they have new posts or not? Thanks.
  9. That might be my problem. How would I divide this among multiple lines for readability?
  10. PHP is new to me and I don't know Javascript. Can you give me the JS code?
  11. I thought this was pretty straight forward, but it is not working. Titlecase is supposed to capitalize the first letter of every with except for certain words in $smallarr. Instead, it capitalizes every word. What's wrong here? //==================================================== function crTitlecase($s) /* Capitalize every word in a sentence except certain small words. */ { //Keep $smallarr in alpha order! //Do not capitalize these words. $smallarr=array('a','above','and','an','at','by','for','if'); $smallarr=array($smallarr,'into','is','it','of','off'); $smallarr=array($smallarr,'on','or','over','the','to'); $smallarr=array($smallarr,'with','without'); //$smallarr=($smallarr,); $t=strtolower($s); //First change all ltrs to lowercase. $words = explode(' ', $t); foreach ($words as $mykey => $word) { //if ((!$mykey) or (!in_array($word, $smallarr)) ) if ( (!in_array($word, $smallarr)) ) { $s='mykey='.$mykey.', word='.$words[$mykey]; crDebug($s); $words[$mykey] = ucwords($word); } } $newtitle = implode(' ', $words); return $newtitle; }
  12. I am using <input type="submit">. I will look into your suggestions. Thanks.
  13. PHP 2.11.10 I have a php page that loads. It takes about 4-5 seconds because I am constructing a select/combo box with 2400 records. While the whole page is loading I would like to make the cursor an hourglass while the cursor is over the PHP page, so the user cannot click on anything until the page is done loading. During production I expect 10,000 records in this combo box so disabling user input while the page is loading becomes more important. How do I do that?
  14. I have multiple table rows on a screen which look like this: [pre] Group name | Copy items from Group Group1 | cbxCopyfrom [cmdCopyitems] Group2 | cbxCopyfrom [cmdCopyitems] Group3 | cbxCopyfrom [cmdCopyitems] [/pre] The table lists a group name, one per row. Each combo/select box lists all groups EXCEPT the one in the current row. Next to the combo/select box is a button cmdCopyitems. Sometimes we want to copy multiple items from Group2 to Group1. So in the row of Group1, in the combo box we choose Group2, then click the button next to it. When I submit the form like this: if (isset($_POST['cmdCopybullet']) ) { } How do I know which button was clicked? Which row was the button in? And how do I get the value in the cbxCopyfrom in the row where the button was clicked? Or am I going about this the wrong way?
  15. Mysql 4.1.11 How do I reset the auto inc ID on all my tables? They are used as keys. When I finish my testing I want to roll this out to production and reset the IDs.
  16. I just go to www.w3schools.com. They have a summary of everything like PHP, MySQL, HTML, CSS, Javascript, and more.
  17. I double checked the <td> element and you're right. Thanks. I thought I saw "halign" somewhere but I was wrong.
  18. I have several controls in a table cell like this: $s.='<td>From <select name="cbx"><option value="test">test</select>'; $s.=' <input type="submit" value="Copy" name="cmdCopyBullet" />'; Look at the second line. In IE 6.0 the   shows up as a box. I don't want to see a box. I want to see a space between my combo box and the submit button. How do I do this? Firefox 3.6 seems to show a space just fine. Thanks.
  19. PHP 2.11.10 I display arrays of controls in tables on a lot of my screens. There are often multiple items related to one part number. Sometimes I want to display a checkbox in this table and center it. But the checkbox won't center. Here is my code: $s='<tr><td><input type="text" id="txtBid[]" name="txtBid[]" size="5" '. 'value="'.$bid.'" readonly />'; $s.='<td><input class="requiredfield" type="text" id="txtBrand[]" name="txtBrand[]" '. 'size="40" maxlength="25" value="'.$b.'" />'; $s.='<td><input class="requiredfield" type="text" id="txtNumgrades[]" '. 'name="txtNumgrades[]" '. 'size="4" maxlength="4" value="'.$numgrades.'" />'; [b] $s.='<td halign="center"><input type="checkbox" value="1" name="chkPnoverride[]" '; if ($override==1) { $s.='checked="checked"'; } $s.='/>';[/b]
  20. Ah, so there potentially could be confusion if UserA and UserB are looking/editing the same part at the same time, and UserA hits the Save button, then UserB hits the save button on the same part. UserB's info will overwrite that of UserA.
  21. Mysql 4.1.11 Let's say I have an edit screen where the user1 edits an already existing record. The data is grabbed using a SELECT query. After he is done editing he clicks the Save button which calls an UPDATE query to save the record. Let's say this is a multi-user system. If the record is being edited by user2 when user1's UPDATE query is run, is it locked? Does Mysql try to retry the UPDATE until the record becomes unlocked? I guess my main question is, does Mysql handle locking automatically or does the programmer have to do the locking? Like when user1 edits the record, I do a SELECT statement to get the data. At this point I would like to lock the record so no one else can edit it. (They can view it only.)
  22. Thanks for the help but this is not worth the time involved in coding it. I just thought there was an option I could turn on somewhere to prevent a single row from breaking during print.
  23. I read it on a web page somewhere, don't remember where. But after my testing I see it is not case sensitive. w3schools.com does not even mention case sensitivity.
  24. I believe many of the "page-break" thingies are not supported by Firefox or other browsers. Thanks for trying.
  25. MySQL 4.1.11 My understanding is the LIKE clause is case-sensitive. How do I make it case-insensitive? When my users are adding to a list of names, I want to make sure they don't have that name on file already but in a different case.
×
×
  • 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.