Jump to content

judejitsu

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

judejitsu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the heads up requinix. Really appreciate it!
  2. Hi, quite new here. I am having trouble with a form I am submitting for processing. Here is my code. process.php <?php require("common.php"); if ($_POST['hdd1pn'] == $_POST['hdd2pn'] && $_POST['hdd2pn'] == $_POST['hdd3pn'] && $_POST['hdd3pn'] == $_POST['hdd4pn'] && $_POST['partnumber'] != NULL && $_POST['ctnumber'] != NULL && $_POST['4sn'] != NULL && $_POST['hdd1pn'] != NULL && $_POST['hdd1sn'] != NULL && $_POST['hdd2sn'] != NULL && $_POST['hdd3sn'] != NULL && $_POST['hdd4sn'] != NULL) { $check = "SELECT * FROM dmagorders WHERE ctnumber = :ctnumber"; $check_params = array(":ctnumber" => $_POST['ctnumber']); try { $stmt = $db->prepare($check); $res = $stmt->execute($check_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } if($stmt->rowCount() != 0) { while( $row = $stmt->fetch()) { $foursncheck = $_POST['4sn']; $check_sst = "SELECT * FROM mag_res WHERE serialno LIKE '%$foursncheck%'"; try { $sststmt = $db->prepare($check_sst); $sstresult = $sststmt->execute(); } catch(PDOException $sstex) { die("Failed to run query: " . $sstex->getMessage()); } if($sststmt->rowCount() != 0) { $upd = "UPDATE dmagorders SET hdd1sn = :hdd1sn, hdd2sn = :hdd2sn, hdd3sn = :hdd3sn, hdd4sn = :hdd4sn, stage = :stage, status = :status, lasttouch = :lasttouch, lastupdate = :lastupdate WHERE ctnumber = :ctnumber AND 4sn = :4sn"; $params = array( ":ctnumber" => $_POST['ctnumber'], ":4sn"=> strtoupper(str_pad($_POST['4sn'], 8, "0", STR_PAD_LEFT)), ":hdd1sn"=> $_POST['hdd1sn'], ":hdd2sn"=> $_POST['hdd2sn'], ":hdd3sn"=> $_POST['hdd3sn'], ":hdd4sn"=> $_POST['hdd4sn'], ":stage" => "8", ":status" => "Packed and Shipped", ":lasttouch" => $_SESSION['user']['fname']." ".$_SESSION['user']['lname'], ":lastupdate" => date('F d, Y [ h:i:s A O ]'), ); try { $updstmt = $db->prepare($upd); $updres = $updstmt->execute($params); header("Location: pack-dmag.php?stat=success"); exit(); } catch(PDOException $updex) { die("Failed to run query: " . $updex->getMessage());; exit(); } } else { header("Location: pack-dmag.php?stat=nosstdata"); exit(); } } } } else { header("Location: pack-dmag.php?stat=nodata"); exit(); } My problem is that this page is actually working for some forms, however, sometimes, it just shows a blank page and doesn't redirect back to pack-dmag.php. There are also no errors or warning messages. Just a single blank page. Any help is greatly appreciated. I am just still learning PHP. If you have suggestions to optimize my code, it is also greatly appreciated.
  3. Hi guys, I have this chunk of code, I need to find out why it doesn't find the nodeValue for some parts of my HTML file. <?php $string = ' <p> <b>HEADER INFO</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>View Object:</b> 6600422</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>BPO:</b> G37147359-000000</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Ack Date:</b> 2012-05-28</font></td> </tr> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=3><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Operation(s):</b> PPS_Queue, PPS_Build, PPS_BoxAll, JPN_End</font></td> </tr> </table> </p> <hr> <p> <b>EXTERNAL ORDER NUMBER REFERENCE</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>SAP Sales Order Number</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Customer P.O. Number</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Legacy Order Number</b></font></td> </tr> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">0310363858</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">77340892008-120413</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">89FF09378001</font></td> </tr> </table> </p> <hr> <p> <b>PRODUCTS FOR THIS WORK OBJECT/OPERATION(S)</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>PL</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Product #</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Qty</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Options</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Serial #</b></font></td> </tr> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">3C</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">AP703B</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">1</font></td> <td valign=top colspan=1>&nbsp </td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">2S6219000G</font></td> </tr> </table> </p> <hr> <p> <b>Station Info</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Start Station:</b> JPN_End</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Location:</b> Done</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Station:</b> </font></td> </tr> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Birth Date/Time:</b> 2012-05-23 14:20:32 SGT</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Power Cord:</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Voltage:</b></font></td> </tr> </table> </p> <hr> <p> <b>MATERIAL LIST FOR THIS WORK OBJECT/OPERATION(S)</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Part Number</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Qty</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Description</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>BB Type</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Material Location</b></font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"><b>Serial Number</b></font></td> </tr> <tr align=left> <td width=2% colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\"> </font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">AP703B@@</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">1</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">OEM Generic 1U SAS Enclosure</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">BOM</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">ASSY</font></td> <td valign=top colspan=1><font face=\"verdana, arial, helvetica\" size=\"-2\">2S6219000G</font></td> </tr> </table> </p> '; $result = parse_data($string); extract($result); echo $headertext.'<br />'; echo $sapSON.'<br />'; echo $custPON.'<br />'; echo $legacyON.'<br />'; echo $pl.'<br />'; echo $pn.'<br />'; function parse_data($string){ $string = str_replace(' ','',$string); $xml = new DOMDocument(); @$xml->loadHTML($string); $ret = array(); foreach($xml->getElementsByTagName('p') as $p) { $header = trim($p->nodeValue); } foreach($xml->getElementsByTagName('td') as $td) { $value = trim($td->nodeValue); if(!empty($value) && is_numeric($value{0})){ $ret[] = $value; } } $ret = array('headertext'=>$header, 'sapSON'=>$ret[0], 'custPON'=>$ret[1], 'legacyON'=>$ret[2], 'pl'=>$ret[3], 'pn'=>$ret[4],); return $ret; } ?> Problem is, the $pn variable doesn't display the value instead jumps to the next <td> which contains the QTY value.
  4. Okay, what if I will just parse the HTML file, so lets say my file contains: <b>EXTERNAL ORDER NUMBER REFERENCE</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face="verdana, arial, helvetica" size="-2"> </font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>SAP Sales Order Number</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Customer P.O. Number</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Legacy Order Number</b></font> </td> </tr> <tr align=left> <td width=2% colspan=1><font face="verdana, arial, helvetica" size="-2"> </font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">0310363858</font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">77340892008-120413</font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">89FF09378001</font> </td> </tr> </table> </p> <hr> <p> <b>PRODUCTS FOR THIS WORK OBJECT/OPERATION(S)</b> <table width=100% cellspacing=0> <tr align=left> <td width=2% colspan=1><font face="verdana, arial, helvetica" size="-2"> </font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>PL</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Product #</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Qty</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Options</b></font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2"><b>Serial #</b></font> </td> </tr> <tr align=left> <td width=2% colspan=1><font face="verdana, arial, helvetica" size="-2"> </font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">3C</font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">AP703B</font> </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">1</font> </td> <td valign=top colspan=1>&nbsp </td> <td valign=top colspan=1><font face="verdana, arial, helvetica" size="-2">2S6219000G</font> </td> </tr> </table> Say the header is on top of the cell with the value, can I parse this and save to variable? like say: $sapsalesorderno = 0310363858; etc... Thanks for the replies!
  5. Thank you for the reply Kays, yes i know. But I have no choice, because this file is generated by a script that I do not have my hands on to. I also do not have access to the database of this program. That's why I am trying to find a workaround which will parse thru the text file and get the variables so i can insert them into my own database and create a report out of it.
  6. Thanks barry! I'll try this one out, someone also told me this can be done via regex, though i am not really sure how to do it... I'll try this one..
  7. Hi guys, I need help in parsing a text file. This text file has a few html tags in it. What I am looking for is a Solution (Either in PHP or JS or both) which will strip all these, and store the output into separate variables. Integration/QA <http://shopfloor/sfweb/secure/CancelOrders> Development <http://shopfloor/sfweb/secure/CancelOrders> ------------------------------------------------------------------------ *HEADER INFO* *View Object:* 6541997 *BPO:* 0020064484 *Ack Date:* 2012-05-25 *Operation(s):* PS_Queue, PS_BoxAll, JPN_End ------------------------------------------------------------------------ *EXTERNAL ORDER NUMBER REFERENCE* *SAP Sales Order Number* *Customer P.O. Number* *Legacy Order Number* 0310407774 89FC37763001 ------------------------------------------------------------------------ *PRODUCTS FOR THIS WORK OBJECT/OPERATION(S)* *PL* *Product #* *Qty* *Options* *Serial #* LN AE241A 1 ------------------------------------------------------------------------ *Station Info* *Start Station:* JPN_End *Location:* Done *Station:* *Birth Date/Time:* 2012-05-22 08:26:17 SGT *Power Cord:* *Voltage:* ------------------------------------------------------------------------ *MATERIAL LIST FOR THIS WORK OBJECT/OPERATION(S)* *Part Number* *Qty* *Description* *BB Type* *Material Location* *Serial Number* AE241-90001 1 XP Remote Support Service Leaflet BOM PACK Privacy Statement I basically Want to strip a few text from this code into php variables, so it will return: $viewobject = "6541997" $BPO = "0020064484" $ackdate = "2012-05-25" and the likeso I can later process these variables. Is this possible?
  8. Thanks for all the replies. I finally figured out the mistake. The date was 23 not 24.
  9. Thank you for the reply... Yes, I have. Here's a sample output if I exclude the BETWEEN clause.
  10. Thanks. It's still the same. Here's the preformatted output: SELECT salesorder, masterproduct, family, COUNT(*) as total FROM report WHERE family='F201_PWS_PF' AND birthstamp BETWEEN '2012-05-24 12:00:00' AND '2012-05-24 16:00:00' GROUP BY salesorder, masterproduct, family However, when I change it to : $sql = mysql_query("SELECT salesorder, masterproduct, family, birthstamp, duedate, COUNT( * ) AS total FROM report WHERE family = '$family' GROUP BY salesorder, masterproduct, family, birthstamp, duedate "); It actually works fine, but the problem is it stops working when I add the BETWEEN clause: $sql = mysql_query("SELECT salesorder, masterproduct, family, birthstamp, duedate, COUNT( * ) AS total FROM report WHERE family = '$family' AND birthstamp BETWEEN '$startDT' AND '$endDT' GROUP BY salesorder, masterproduct, family, birthstamp, duedate "); please note that the $startDT and $endDT variables are fetched from a post and then I just concatenated some text to fill the remaining date time. $startDT = $_POST['birthstamp']." ".$_POST['hour'].":00:00"; $endDT = $_POST['birthstamp']." ".$_POST['hour2'].":00:00"; Thank you for your help ... Really appreciate it...
  11. Thank you for that! It's working, however it returns zero rows instead of returning all rows which qualifies from the sql query... Here's the part of the code : $family = $_POST['family']; $startDT = $_POST['birthstamp']." ".$_POST['hour'].":00:00"; $endDT = $_POST['birthstamp']." ".$_POST['hour2'].":00:00"; //$sql = mysql_query("SELECT * FROM report WHERE family='$family' AND birthstamp BETWEEN '$startDT' AND '$endDT'") or die(mysql_error()); $sql = mysql_query("SELECT salesorder, masterproduct, family, COUNT(*) as total FROM report WHERE family='$family' AND birthstamp BETWEEN '$startDT' AND '$endDT' GROUP BY salesorder, masterproduct, family") or die(mysql_error()); if(mysql_num_rows($sql) == 0) { echo "<center><h3 style=\"color=red\">Sorry, no Orders with those parameters are saved in the database. Please import a New CSV with that range.</h3></center>"; } else { echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"data\"> <tr> <td class=\"dataHeader\">Sales Order</td> <td class=\"dataHeader\">Sales Order Code</td> <td class=\"dataHeader\">Family</td> <td class=\"dataHeader\">Product Code</td> <td class=\"dataHeader\">Quantity</td> <td class=\"dataHeader\">Birth Stamp</td> <td class=\"dataHeader\">Due Date</td> </tr> "; while($result = mysql_fetch_array($sql)) { echo " <tr> <td class=\"data\">".$result['salesorder']."</td> <td class=\"data\"><span class=\"title\">*".$result['salesorder']."*</span><br />".$result['salesorder']."</td> <td class=\"data\">".$result['family']."</td> <td class=\"data\"><span class=\"title\">*".$result['masterproduct']."*</span><br />".$result['masterproduct']."</td> <td class=\"data\">"; //need to echo the value here echo "</td> <td class=\"data\">".$result['birthstamp']."</td> <td class=\"data\"><span class=\"title\">*".$result['duedate']."*</span><br />".$result['duedate']."</td> </tr> "; } echo "</table>"; } Thank you so much for your help...
  12. I cannot make it to work. I changed the $sql from my code above to this: $sql = mysql_query("SELECT salesorder, masterproduct, family, COUNT(*) as total FROM report GROUP BY salesorder, masterproduct, family, WHERE family='$family' AND birthstamp BETWEEN '$startDT' AND '$endDT'") or die(mysql_error()); Am I doing something wrong? Because my program output becomes :
  13. Thank you for the fast reply, will try this out
  14. Hi guys, I am learning PHP on my own. I have this small office project where my script fetches data from a mysql database. I am having problems though with the query. I need to merge rows of the same column data and count its occurrence. Say, table report: Col1___Col2___Col3 AAA____BBB___CCC AAA____BBB___CCC XXX____MMM___NNN Basically, I need to do this as output to PHP: Col1___Col2___Col3___qty AAA____BBB___CCC___2 XXX___MMM__NNN___1 Here's part my script : $conn = mysql_connect("localhost", "root", "123456") or die(mysql_error()); mysql_select_db("store") or die(mysql_error()); // $masterproduct = $_POST['masterproduct']; $family = $_POST['family']; $startDT = $_POST['birthstamp']." ".$_POST['hour'].":00:00"; $endDT = $_POST['birthstamp']." ".$_POST['hour2'].":00:00"; $sql = mysql_query("SELECT * FROM report WHERE family='$family' AND birthstamp BETWEEN '$startDT' AND '$endDT'") or die(mysql_error()); if(mysql_num_rows($sql) == 0) { echo "<center><h3 style=\"color=red\">Sorry, no Orders with those parameters are saved in the database. Please import a New CSV with that range.</h3></center>"; } else { echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"data\"> <tr> <td class=\"dataHeader\">Sales Order</td> <td class=\"dataHeader\">Sales Order Code</td> <td class=\"dataHeader\">Family</td> <td class=\"dataHeader\">Product Code</td> <td class=\"dataHeader\">Quantity</td> <td class=\"dataHeader\">Birth Stamp</td> <td class=\"dataHeader\">Due Date</td> </tr> "; while($result = mysql_fetch_array($sql)) { echo " <tr> <td class=\"data\">".$result['salesorder']."</td> <td class=\"data\"><span class=\"title\">*".$result['salesorder']."*</span><br />".$result['salesorder']."</td> <td class=\"data\">".$result['family']."</td> <td class=\"data\"><span class=\"title\">*".$result['masterproduct']."*</span><br />".$result['masterproduct']."</td> <td class=\"data\">"; //need to echo the Quantity value here echo "</td> <td class=\"data\">".$result['birthstamp']."</td> <td class=\"data\"><span class=\"title\">*".$result['duedate']."*</span><br />".$result['duedate']."</td> </tr> "; } echo "</table>"; } ?> I will be very thankful if someone can help me what I need to do with my script. Thank you!
×
×
  • 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.