Jump to content

BrettCarr

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by BrettCarr

  1. <?php $mystring = "This is my test string that has {['site_info']} and some more stuff {['taste']} then nothing" ?>
  2. Array ( [0] => Array ( [0] => 11-1-89677-362123164 [1] => 11 [2] => testadmin [3] => 61415676836 [4] => 2011-11-16 [5] => 1 [6] => 0 [7] => 0 [8] => [9] => 0 [10] => 0 [11] => 0 ) [1] => Array ( [0] => 11-1-89688-362186603 [1] => 11 [2] => testadmin [3] => 61415556677 [4] => 2011-08-12 [5] => 0 [6] => 0 [7] => 0 [8] => [9] => 0 [10] => 0 [11] => 0 ) [2] => Array ( [0] => 11-1-89689-362186773 [1] => 11 [2] => testadmin [3] => 61415676836 [4] => 2011-08-12 [5] => 0 [6] => 0 [7] => 0 [8] => [9] => 0 [10] => 0 [11] => 0 ) [3] => Array ( [0] => 11-1-89690-362186926 [1] => 11 [2] => testadmin [3] => 61415223344 [4] => 2011-08-12 [5] => 0 [6] => 0 [7] => 0 [8] => [9] => 0 [10] => 0 [11] => 0 ) ) $final = array(); foreach ($phoneNumberArray as $array[3]) { if(!in_array($array, $final)){ $final[] = $array; } } print_r($final);
  3. <?php $cc = '61'; $ac = '4'; $ph = '8'; $ext = '/0/'; $phoneNumber = '610415676836'; //ok try this $pattern = "'/^$cc([$ac]{1})([0-9]{{$ph}})$/'"; echo $pattern."<br />"; $numlen = strlen($phoneNumber); if($numlen = 12){ $phoneNumber1 = preg_replace($ext,'',substr($phoneNumber,3)); //echo $phoneNumber1; $phoneNumberComplete = $cc.$phoneNumber1; echo $phoneNumberComplete."<br />"; } if(preg_match($pattern, $phoneNumberComplete))// this doen't seem to work { echo "Oh yeh"; } else { echo "boo hiss"; } if(preg_match('/^61[4]{1}[0-9]{8}$/', $phoneNumberComplete))// this does work { echo 'is true'; } else { echo "not doing it"; } //please help ?>
  4. $testemail = '(bobbyboo@sample.com.au)'; echo $testemail; $testemail2 = trim(preg_replace('/^[\(]/', '', $testemail)); echo $testemail2."<br />"; $testemail3 = trim(preg_replace('/$\)/','', $testemail2)); echo $testemail3."<br />";
  5. <?php class User extends Database { function read() { $this->query("SELECT * FROM sales_peepl;"); } function delete($id) { $this->query("DELETE * FROM sales_peepl WHERE salesid = {$id};"); } function output() { return $this->_row->sales_person ." - ". $this->_row->access . " " . '<a href="?=action=$this->delete&id='.$this->_row->salesid.'">delete</a>' . "<br/>"; } } ?> <?php include_once($_SERVER['DOCUMENT_ROOT'] . '/sales/includes/global.php'); $t = new User(); $t->connect(HOST, USERNAME , PASSWORD, DATABASE); $t->read(); ?> <html><head><title></title> </head> <body> <?php while ( $t->next()) { echo $t->output() . " "; } ?> </body> </html>
  6. Cool you were right session_start() was the problem i didn't have it in the ajax file..... Thanks Man.. Now its beer time
  7. function addDatadb() { myarray = <?= json_encode($_SESSION['batcharray']) ?>; send( '/ajax/arrayclean.php', 'myarray=' + myarray, null , addDatadbRecv ); } function addDatadbRecv(data) { $_SESSION['batcharray'] = data; } this is whats in ajax/arrayclean.php <?PHP include_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.php'); $db = new Database(); $db->connect(); $batcharry = $_REQUEST['myarray']; $parts = array_map(create_function('$e', 'return implode("','", $e);'), array_chunk(explode(',', $batcharry), 13)); //var_dump($parts); foreach ($parts as $value) { $comma_separated = implode("','", $value); //var_dump($comma_separated); eval("\$comma_separated = \"$comma_separated\";"); $myquery = "INSERT INTO batch_import VALUES(null,'$comma_separated','0');"; //echo $myquery . "<br />"; $db->query($myquery); } if (isset($_REQUEST['myarray'])) { unset($_REQUEST['myarray']); echo $_REQUEST['myarray']; } ?> so when$_REQUEST['myarray'] is emptied im sending back to client side and want to replace whatsin $_SESSION['batcharray'] with whats in data.... nothing
  8. <?php $teststring = "2010-03-14,74527,645,New,7417417,Toll,2,74527417,32,202,7452741741,ghtgbwt,gtgwtgwtfgwtrg,2010-03-14,857527527,645,New,7417418,Toll,7,74527418,32,202,527527,hjm,djmdmdjmdjmdgjm,2010-03-14,85285,645,New,7417419,Toll,2,74527419,32,202,750757,jryjkryjkfryk,yjmyjyjtyjhm"; $teststring1 = preg_replace("/([a-zA-Z0-9_\-]+?),/" , "\"$1\",",$teststring); $teststring2 = preg_replace("/\,{13}/" , "],[",$teststring1); var_dump($teststring2); ?>
  9. <?php public function getArrayData() { $batchdate1 = date('Y-m-d', strtotime(preg_replace('/\//','-',$_POST['batch_date']))); if (isset($_POST['batch_number'])) { $_SESSION['batcharray'][] = array( "batch_date" => $batchdate1, "batch_number" => $_POST['batch_number'], "original_proof_num" => $_POST['original_proof_num'], "batch_status" => $_POST['batch_status'], "invoice_num_ccaus" => $_POST['invoice_num_ccaus'], "carrier" => $_POST['carrier'], "num_of_boxes" => $_POST['num_of_boxes'], "toll_consign_num" => $_POST['toll_consign_num'], "custId" => $_POST['custId'], "venueId" => $_POST['venueId'], "bpay" => $_POST['bpay'], "proof_tracking_comments" => $_POST['proof_tracking_comments'], "veunue_comments" => $_POST['veunue_comments'], ); } } ?> <?php public function myJsonString() { $test = json_encode($_SESSION['batcharray']); $str = "(". $test .")" ; var_dump($str); eval("\$str = \"$str\";"); var_dump($str); $str = substr($str, 1, strlen($str) - 2); // remove outer ( and ) $str = preg_replace("/([a-zA-Z0-9_]+?):/" , "\"$1\":", $str); // fix variable names echo "<br/>"; echo "Ok string is created" ."<br/>"; $_SESSION['myJsonString'] = $str; //var_dump($str); //$output = json_decode($str, true); //var_dump($output); }?> <script language="javascript" type="text/javascript" src="/scripts/network.js"></script> <script language="javascript" type="text/javascript"> function addDatadb() { myarray = <?= $_SESSION['myJsonString'] ?>; send( '/ajax/arrayclean.php', 'myarray=' + myarray, null , null); alert(myarray); } <?php $str = $_REQUEST['myJsonString']; var_dump($str); $output = json_decode($str, true); var_dump($output); foreach ($output as $ojb) { $comma_separated = implode("','", $ojb); $myquery = "INSERT INTO batch_import VALUES(null,'$comma_separated','0');"; echo $myquery . "<br />"; $db->query($myquery); } ?>
  10. Hi im new to forums and im not sure what i'm doing wrong I can't get an answer for my problem, am i setting it out wrong or somthing, I really need help and im fairly new to php I want to add the POST from a form to a multi dimensional array, I have started making a class called Batcharray, When the submit button is clicked It calls Batcharray This is whats in Batcharray <?php class Batcharray extends Database { function getArrayData() { $batch_date = $_POST['batch_date']; $batch_number = $_POST['batch_number']; $original_proof_num = $_POST['original_proof_num']; $batch_status = $_POST['batch_status']; $invoice_num_ccaus = $_POST['invoice_num_ccaus']; $carrier = $_POST['carrier']; $num_of_boxes = $_POST['num_of_boxes']; $toll_consign_num = $_POST['toll_consign_num']; $custId = $_POST['custId']; $venueId = $_POST['venueId']; $bpay = $_POST['bpay']; $proof_tracking_comments = $_POST['proof_tracking_comments']; $veunue_comments = $_POST['veunue_comments']; $batchlist = array( "batcharray" => array( "batch_date" => $batch_date, "batch_number" => $batch_number , "original_proof_num" => $original_proof_num, "batch_status" => $batch_status, "invoice_num_ccaus" => $invoice_num_ccaus, "carrier" => $carrier, "num_of_boxes" => $num_of_boxes, "toll_consign_num" => $toll_consign_num , "custId" => $custId , "venueId" => $venueId, "bpay" => $bpay, "proof_tracking_comments" => $proof_tracking_comments, "veunue_comments" => $veunue_comments, ) ); /*$batchlist = array_merge((array)$batchlist,(array) $batcharray1); print_r( $batchlist );*/ foreach( $batchlist["batcharray"] as $key => $value) { echo "$key, $value <br />"; } reset($batchlist); while (list($key, $val) = each($batchlist)) { echo "$key => $val\n"; } } } ?> and it seem to work for the first time can you help me add a new record I cannot for the life of me figure it out . this is what the out put says on first post Array ( [batcharray] => Array ( [batch_date] => 01-Jan-1970 [batch_number] => 0 [original_proof_num] => 596 [batch_status] => New [invoice_num_ccaus] => 852 [carrier] => Toll [num_of_boxes] => 5252 [toll_consign_num] => 752752752 [custId] => 75275275 [venueId] => 752727 [bpay] => 7427427 [proof_tracking_comments] => 72 [veunue_comments] => 272727272 ) ) so thats where im at, do i need to use array_push, and if so How Thanks in advance Brett
×
×
  • 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.