Jump to content

ainoy31

Members
  • Posts

    370
  • Joined

  • Last visited

    Never

Everything posted by ainoy31

  1. Hello- I have the following info i need to extract out: Del Date/Time:</td><td class="text" width='90' bgcolor='#f5f5dc'><b>01/31/08<BR>11:20 AM</b></td> I have tried the following to just get the date out. //$pat = '~Del Date/Time:\</td><td class="text" width=\'90\' bgcolor=\'#f5f5dc\'\></b>.*?(\d{2}/\d{2}/\d{2})<BR\>~s'; preg_match_all($pat, $line, $matches); print_r($matches); My matches array is empty. Much appreciation. AM
  2. Hello- I need help determine why this code is not working. Seems like my logic is correct. So, I have two arrays: #1 - Array ( [0] => Array ( [0] => Del Date/Time:01/31/08 ) [1] => Array ( [0] => Del Date/Time ) [2] => Array ( [0] => 01/31/08 ) ) #2 - Array ( [0] => Array ( [0] => Cur Status:Delivered ) [1] => Array ( [0] => Delivered ) ) Here is my code that I need help with: if(stristr($line, 'Del Date/Time:')) { $pat = '#(Del Date/Time):.*?(\d{2}/\d{2}/\d{2})#is'; preg_match_all($pat, $line, $matches); $deliv_date = date("Y-m-d", strtotime( $matches[2][0] ) ); $delivered = true; }//end of if(stristr($line, 'Del Date/Time:')) if(stristr($line, 'Cur Status:')) { $pat = '~Cur Status:\</td\><td class="text" width=\'90\' bgcolor=\'#f5f5dc\'\>((??!\</td\>).)+)\</td\>~s'; preg_match_all($pat, $line, $matches); $status = $matches[1][0]; if($status != 'Delivered') { $deliv_date = null; $delivered = false; } } return array($delivered, false, $status, $deliv_date); The problem is that if status does not equal 'Delivered', then it should not set the $deliv_date to null and $delivered to false. However, in my case it does and overwrites the previous $deliv_date value. Right, if $status does not equal 'Delivered', then $deliv_date = null; and $delivered = false; should not be executed? I hope this is pretty clear. Maybe I am overlooking something simply here. Much appreciation.
  3. Solution given works. Thanks.
  4. Thanks for the suggestion and will try it out...
  5. Hello- I have a little problem updating a record in my table. Here is the structure of my table. CREATE TABLE commodity ( com_id serial NOT NULL, quote_id integer NOT NULL, com_name varchar(50) NOT NULL, htsus varchar(50) NOT NULL, eccn varchar(50) NULL The quote_id is a foreign key of another table. So right now I have a record with quote_id of 71 with two com_id's of 104 and 105 respectively. So com_id 104 has com_name of Shoes with htsus of 1252.25.3652 and com_id 105 has com_name of Dresses with htsus of 1524.25.3652. I am trying to have a page where someone can come in and edit these records. Here is the form code to do so: <table> <tr> <td>Commodity and HTSUS #:</td> </tr> <tr> <td><? $sql = "SELECT com_name, htsus FROM commodity WHERE quote_id = '$id'"; $res = pg_query($sql); while($c = pg_fetch_assoc($res)) { ?> <input type="text" name="com[]" value="<? echo $c[com_name]; ?>" size="20" > <input type="text" name="htsus[]" value="<? echo $c[htsus]; ?>" size="20" /><br> <? } ?> </td> </tr> Then I request the posted data and update the record as follows: $com = $_REQUEST["com"]; $ht = $_REQUEST["htsus"]; foreach($com as $key => $var) { pg_query("UPDATE commodity SET com_name = '$var', htsus = '$ht[$key]' WHERE quote_id = '$id'") or die("Error in Query: " . pg_last_error()); } The problem is that I have a duplicate record of whatever I enter first. So if I have quote id if 54 with three com_id, all the com_id will have the same info. I hope this is clear enough of what I am trying to do. Much appreciation. AM
  6. The work around what I need is that I pass three variables in the URL and then check to make sure that all three values correspond to each other. Meaning if I had www.xxx.com/xxx.php?a=$id&b=$em&c=$pn, someone can not say just change one of the variables and access other quotes.
  7. I am trying to see how this is for me. I want my users not to see the value of the id when they click on the link in their email. So, right now they see http://xxx.php?y=100"; but I need it to be http://xxx.php?y=$id";
  8. Hello- I am sending emails with a hyperlink in the body where my users can click on and it will take them to a certain page. $body .= "http://xxx.php?y=$id"; Is there a way not to make the $id value visible? Meaning, in the email they see $body .= "http://xxx.php?y=100"; Much appreciation.
  9. In my javascript I use document.getElementById('total_sell').value = num; and document.getElementById('total_buy').value = num; for the input text area I use this segment of code: <td> <label for="total_buy">Total Buy Price:</label> <input type="text" name="total_buy" size="15" class="readonly" id="total_buy" READONLY> <!--<span class='total_buy'> 0</span>--> </td> </tr> <tr> <td> <label for="total_sell">Total Sell Price:</label> <!--<span class='total_sell'> 0</span>--> <input type="text" name="total_sell" size="15" class="readonly" id="total_sell" READONLY> </td>
  10. Hello- I have a form that I use javascript to total up the total cost. I need to post the total cost data to another page. I am using the span tag to capture it. Here is my code: Javascript: function add_buy() { $('input.buy').keyup(function() { total_buy = 0; $('tr.group').each(function() { buy = $(this).find('input.buy').val(); total_buy = total_buy + Number(buy); buy_sum = $('span.total_buy'); buy_sum.text(total_buy,true); }); }); }//end of function add_buy() The form code is: <table> <tr> <td> <label for="total_buy">Total Buy Price:</label> <input type="hidden" name="total_buy" id="total_buy" /><span class='total_buy'> 0</span> </td> </tr> I tried using the $_POST['total_buy'] or $_REQUST['total_buy'] but no luck. I am missing something stupid here. Much appreciation. AM
  11. Hello- I have a dynamic form and I display certain questions base on what button is clicked. The form works fine but when I go back to check what I have picked, two of my questions are missing the radio buttons. So, say I choose No and No for the Letter of Credit and Is an original Bill of Lading required, and go back to view it, the button for the No is missing but available for the Yes option. Here is my code: <td> <input type="radio" style="background-color:white" rel="credit" id="ff_quote" name="ff_quote" value="Yes">Yes <input type="radio" style="background-color:white" rel="none" id="ff_quote" name="ff_quote" value="No">No </td> </tr> <tr rel="credit"> <td class="label"> Letter of Credit?</td> <td> <input type="radio" style="background-color:white" rel="or_bl" name="credit" value="Yes">Yes <input type="radio" style="background-color:white" rel="usppi_shipper_same" name="credit" value="No">No </td> </tr> <tr rel="or_bl"> <td class="label"> Is an original Bill of Lading required?</td> <td> <input type="radio" style="background-color:white" rel="usppi_shipper_same" name="or_bl" value="Yes">Yes <input type="radio" style="background-color:white" rel="usppi_shipper_same" name="or_bl" value="No">No </td> </tr> <tr rel="usppi_shipper_same"> <td class="label"><a href="intldoc/15cfr30.4.pdf" onMouseOver="stm(Text[7], Style[7]);" onMouseOut="htm();" target="blank"><img src="/images/fam/help.gif" class="button" alt=''></a> USPPI and Shipper the same?</td> <td> <input type="radio" style="background-color:white" rel="none" name="usppi_shipper_same" value="Yes" onClick="hideAll(); changeDiv('ex_com', 'block');">Yes <input type="radio" style="background-color:white" rel="usppi_detail" name="usppi_shipper_same" value="No">No </td> </tr> I hope this not is confusing. This only happens in IE7 but works fine in firefox. Much appreciation. AM
  12. Yeah. I replaced the 3 with a 4 and that fixed my issue. For some reason I was thinking the count starts from 0.... on up like an array. Thanks. AM
  13. Hello- I have a javascript that auto formats a text field as numbers are entered. So, if you enter 1111223333, then it will be 1111.22.3333. Here is the script I am using: var aChar = new Array(' ', '(', ')', '-', '.'); var maxhtsuslength = 12; var htsus1; var htsus2; var cursorposition1; function ParseForNumber3(object) { htsus1 = ParseChar1(object.value, aChar); } function ParseForNumber4(object) { htsus2 = ParseChar1(object.value, aChar); } function backspacerUP1(object,e) { if(e) { e = e } else { e = window.event } if(e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber3(object) if(keycode >= 48) { ValidateNumber(object) } }//end of function backspacerUP(object,e) function backspacerDOWN1(object,e) { if(e) { e = e } else { e = window.event } if(e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber4(object) }//end of function backspacerDOWN(object,e) function Getcursorposition1() { var t1 = htsus1; var t2 = htsus2; var bool = false for (i=0; i<t1.length; i++) { if (t1.substring(i,1) != t2.substring(i,1)) { if(!bool) { cursorposition1=i bool=true } } } }//end of function Getcursorposition1() function ValidateNumber(object) { var p = htsus1 p = p.replace(/[^\d]*/gi,"") if (p.length < 4) { object.value=p } else if(p.length==4) { pp=p; d4=p.indexOf('.') if(d4==-1) { pp=pp+"."; } object.value = pp; } else if(p.length>4 && p.length < 7) { p =p + "."; l30=p.length; p30=p.substring(0,4); p30=p30+"." p31=p.substring(4,l30); pp=p30+p31; object.value = pp; } else if(p.length >= 7) { p =p + "."; l30=p.length; p30=p.substring(0,3); p30=p30+"." p31=p.substring(3,l30); pp=p30+p31; l40 = pp.length; p40 = pp.substring(0,7); p40 = p40 + "." p41 = pp.substring(7,l40); ppp = p40 + p41; object.value = ppp.substring(0, maxhtsuslength); } Getcursorposition1() if(cursorposition1 >= 0) { if (cursorposition1 == 0) { cursorposition1 = 3 } else if (cursorposition1 <= 3) { cursorposition1 = cursorposition1 + 1 } else if (cursorposition1 <= 6) { cursorposition1 = cursorposition1 + 2 } else if (cursorposition1 == 6) { cursorposition1 = cursorposition1 + 2 } else if (cursorposition1 == 7) { cursorposition1 = cursorposition1 + 3 e1=object.value.indexOf('.') e2=object.value.indexOf('.') if (e1>-1 && e2>-1) { if (e2-e1 == 4) { cursorposition1 = cursorposition1 - 1 } } } else if (cursorposition1 < 10) { cursorposition1 = cursorposition1 + 3 } else if (cursorposition1 == 10) { cursorposition1 = cursorposition1 + 1 } else if (cursorposition1 >= 11) { cursorposition1 = cursorposition1 } }//end of if(cursorposition1 >= 0) }//end of function ValidatePhone(object) function ParseChar1(sStr, sChar) { if (sChar.length == null) { aChar = new Array(sChar); } else aChar = sChar; for (i=0; i<aChar.length; i++) { sNewStr = ""; var iStart = 0; var iEnd = sStr.indexOf(sChar[i]); while (iEnd != -1) { sNewStr += sStr.substring(iStart, iEnd); iStart = iEnd + 1; iEnd = sStr.indexOf(sChar[i], iStart); } sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length); sStr = sNewStr; }//end of for (i=0; i<aChar.length; i++) return sNewStr; }//end of function ParseChar(sStr, sChar) <input type="text" name="htsus" onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" /> The format comes out as 111.122.3333 but need it to be 1111.22.3333. I am probably missing something stupid since I have been coding too long. Much appreciation. AM
  14. Hello- I have data that is in an array that I need to insert into my postgres DB. Here is my array data : foreach($comm as $key => $var) { $comm_htsus = "Commodity: " . $var . ', ' . ' ' . " HTSUS #: {$htsus[$key]}"; echo $commod_htsus . "<br>"; } This is what I have tried: $result = "INSERT INTO intl_quote VALUES(default, now(),'$date', '$c_name', '$c_contact', '$cphone', $commod_htsus)"; $sql = pg_query("$result"); It inserts fine, but if I have more than one element in the array, it only inserts the last one. Much appreciation. AM
  15. I figured it out. The solution is to do the following: <td>Anticipated Ship Date:</td> <td><input type="text" name="ship_date" value="<? echo $q[ship_date]; ?>" /></td> Thanks guys. I overlooked something easy. Been coding too much lately with deadline approaching...
  16. Thanks for all the advice but that is not the case. I am able to echo $q[ship_date] on the second page and it reads out the correct date.
  17. Hello- I am passing a variable in the URL to another page. <? echo "<a href='quote_transaction.php?id=$q[quote_id]&action=Edit'>Edit</a>" ?> On the second page I need to be able to retrieve all the data for that ID. I am going to display all the information and give the option to edit each input field. This is where my problem is. I have tried doing the following: $action = $_GET['action']; $id = $_GET['id']; if(isset($action)) { switch($action) { case 'Edit': $sql = "SELECT * FROM intl_quote WHERE quote_id = '$id'"; $result = pg_query("$sql"); if(!sql) { die("Error in SQL query: " . pg_last_error()); } if(pg_num_rows($result)) { while($q = pg_fetch_array($result)) { <div class="formitem"> <table> <tr> <td>Anticipated Ship Date:</td> <td><input type="text" name="ship_date" value="$q[ship_date]" class="datepicker" /></td> </tr> <tr> <td>Company Name:</td> <td><input type="text" name="company_name" value="$q[company_name]" size="20"/></td> </tr> <tr> <td>Contact Person:</td> <td><input type="text" name="company_contact" value="$q[company_contact]" size="20"/></td> </tr> </table </div> } } } } In the input field, I get $q[ship_date] instead of the actually value. Much appreciation. AM
  18. Hello- I have a script that formats a number with commas such as 888888888 will be 888,888,888. Here is the code: function formatNumber(amount) { var delimiter = ","; var a = amount.split('.',2) var d = a[1]; var i = parseInt(a[0]); if(isNaN(i)) { return ''; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); var n = new String(i); var a = []; while(n.length > 3) { var nn = n.substr(n.length-3); a.unshift(nn); n = n.substr(0,n.length-3); } if(n.length > 0) { a.unshift(n); } n = a.join(delimiter); if(d.length < 1) { amount = n; } else { amount = n + '.' + d; } amount = minus + amount; return amount; } var num = formatNumber(amount); I get the error message that amount.split is not a function. Much appreciation. AM
  19. Figured out my issue. It was my javascript that was erasing the value of my variable.
  20. Hello- I need a second eye my code. I have a drop menu and if someone selects "Other", then a new input text field pops up asking to type their value. Here is the code to do so: <td>Unit Type:</td> <td> <select name="pieces_type" onchange="toggleOther( document.form1.pieces_type.options[ document.form1.pieces_type.selectedIndex ].value );"> <option value="">-Select One-</option> <option value="Pallets">Pallets</option> <option value="Packages">Packages</option> <option value="Totes">Totes</option> <option value="Other_Air">Other - Specify</option> </select> <input type="text" name="Other_Air" value="" size="25" maxlength="40" style="visibility:hidden" /> </td> I am passing this info to the next page. $pt1 = $_POST["pieces_type"]; if($pt1 == 'Other_Air') { $pt3 = $_POST["Other_Air"]; } if($pt1 != 'Other_Air') { $pt3 = $_POST["pieces_type"]; } echo "Type of Units: " . $pt3 . "<br>"; My issue is that if I select Other - Specify and enter my value, it does not get pass properly to the next page. I get the value of Other_Air instead of what I entered say Crates. I am probably overlooking something stupid but been up for 26 hrs now. Much appreciation. AM
  21. I realize that I was using the same name for my radio input as for my DIV ID. I changed the name and it fixed my issue. <tr> <td>Calculate dimension of shipment units?</td> <td> <input type="radio" name="cal_dimen" value="Yes" onClick="hideAll(); changeDiv('cal_dim', 'block'); ">Yes <input type="radio" name="cal_dimen" value="No">No </td> </tr> </table> </div> <div id="cal_dim" style="display:none; "> <br> Originally, i had name="cal_dim" for the radio input name. That was why the Yes button was hidden.
  22. I figured out my issue. I was using the same name for my radio buttons as for my DIV ID. <tr> <td>Calculate dimension of shipment units?</td> <td> <input type="radio" name="cal_dimen" value="Yes" onClick="hideAll(); changeDiv('cal_dim', 'block'); ">Yes <input type="radio" name="cal_dimen" value="No">No </td> </tr> </table> </div> <div id="cal_dim" style="display:none; "> <br> Originally, i had name="cal_dim" for the radio input name. That was why the Yes button was hidden.
  23. Hello- I have two radion buttons, Yes and No on a form. The problem is that the Yes button is missing but not the No button while using IE7. However, it appears in FireFox. I thought it was my javascript but removing it did not fix the issue. Has anyone come across this issue? <tr> <td>Calculate unit dimensions?</td> <td> <input type="radio" name="cal_dim" value="Yes">Yes <input type="radio" name="cal_dim" value="No">No </td> </tr> Thanks. AM
  24. Yes it is and thank you. AM
  25. Hello- I believe my brain is fryed and seem to not be able to think this through. I need help with the following. I have two dynamic arrays. The first array will contain the commodity name such as $comm = Array ( [0] => X [1] => Y [2] => [3] => ... and so forth). The second array contains an unique number to each commodity such as $htsus = Array ( [0] => 12345 [1] => 6789 [2] => ... and so forth). I need to get the format to display as follows: Commodity: X HTSUS: 12345 Commodity: Y HTSUS: 6789 ..... I have tried using the foreach function but no luck. foreach($comm as $var) { echo "Commodity: " . $var . ' '; foreach($htsus as $data) { echo "HTSUS: " . $data <br />"; } } Much appreciation.. AM
×
×
  • 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.