Jump to content

samtwilliams

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by samtwilliams

  1. $itemarrayview = $_SESSION['ItemTotalArray']; unset($i); $i = 0; foreach ($itemarrayview as $v) { foreach($v as $key => $value) { echo '<tr>'; echo '<td>'.$key."</td>"; echo '<td>'.$value."</td>"; echo '<td align="center"><a href="pt_allocate.php?remove=1&asi='.$ASI_index.'&offset='.$i.'">Remove</a></td>'; echo '</tr>'; } $i++; } An example array data; Array ( [1] => Array ( [CD0005] => 2 ) ) I want to put the first array Key ('1' in this example) into my remove link so i can use this code; unset($_SESSION['ItemTotalArray'][$offset]); Thanks Ken
  2. Have just changed that but still cant work out how to return the key from the first array to go in my removal link.
  3. Thanks Ken, I have changed that which has relieved the main issue, except how do i return the array key value, as I need it to remove elements using my remove link, as you can see i use $i in the link but thats not correct if there is 1 element in the array. $itemarrayview = $_SESSION['ItemTotalArray']; unset($i); $i = 0; foreach ($itemarrayview as $value) { foreach($value as $key => $value) { echo '<tr>'; echo '<td>'.$key."</td>"; echo '<td>'.$value."</td>"; echo '<td align="center"><a href="pt_allocate.php?remove=1&asi='.$ASI_index.'&offset='.$value.'">Remove</a></td>'; echo '</tr>'; } $i++; }
  4. I now have this; <?PHP $itemarrayview = $_SESSION['ItemTotalArray']; unset($i); $i = 0; foreach ($itemarrayview as $key => $value) { foreach($itemarrayview[$i] as $key => $value) { echo '<tr>'; echo '<td>'.$key."</td>"; echo '<td>'.$value."</td>"; echo '<td align="center"><a href="pt_allocate.php?remove=1&asi='.$ASI_index.'&offset='.$i.'">Remove</a></td>'; echo '</tr>'; } $i++; } ?> which echo's my multidimensional array in a table, the only thing is if i remove one of them when i remove another i get offset errors everywhere. Anyone kind enough to help? Thanks Sam
  5. I see that now, but struggling to fix it, if i place it within another foreach loop it works but then all my data elements become offset and i cant seem to fix them
  6. For some reason it will only show one result. when ther are multiple in my array. My array data Array ( [0] => Array ( [CD0002] => 7 ) [1] => Array ( [CD0004] => 5 ) [2] => Array ( [CD0006] => 12 ) ) My array <?PHP $itemarrayview = $_SESSION['ItemTotalArray']; foreach($itemarrayview[0] as $key => $value) { echo '<tr>'; echo '<td>'.$key."</td>"; echo '<td>'.$value."</td>"; echo '<td align="center"><a href="pt_allocate.php?remove='.$key.'&asi='.$ASI_index.'">Create</a></td>'; echo '</tr>'; } ?>
  7. Hi All, I have the following array with Partnumber & Qty, I can't seem to find a clean way to check if the partnumber already exists. Because if it does i want to return a message to the user. I load my array like this; $item_array = array($_POST['medsel'], $_POST['qty']); array_push($_SESSION['ItemTotalArray'],$item_array); Example Data; (as you can see i have duplicates which i want to prevent) Array ( [0] => Array ( [0] => CD0003 [1] => 1 ) [1] => Array ( [0] => NA [1] => 1 ) [2] => Array ( [0] => CD0002 [1] => ) [3] => Array ( [0] => CD0001 [1] => 3 ) [4] => Array ( [0] => CD0005 [1] => 1 ) [5] => Array ( [0] => NA [1] => ) [6] => Array ( [0] => NA [1] => ) [7] => Array ( [0] => NA [1] => 2 ) ) Thanks Sam
  8. Can anyone enlighten me as to why i get: Notice: Undefined variable: global_error_reporting in C:\wamp\www\inc\settings.php on line 35. //error handler function function customError($errno, $errstr) { if ($global_error_reporting == 0) { } elseif ($global_error_reporting == 1) { $myFile = $www_location."inc\error_log.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "Error: [$errno] $errstr "; fwrite($fh, $stringData); fclose($fh); } elseif ($global_error_reporting == 2) { echo "<b>Error:</b> [$errno] $errstr"; } elseif ($global_error_reporting == 3) { $myFile = $www_location."inc\error_log.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "Error: [$errno] $errstr "; fwrite($fh, $stringData); fclose($fh); echo "<b>Error:</b> [$errno] $errstr"; } } The variable is set further up the page. Thanks Sam
  9. that wouldnt work as i need to retieve each individual peice of data and set it to a variable e.g. set dob to $dob etc.
  10. It just states 'Array' It is a multidimensional array some example data; Array ( [0] => Array ( [patientid] => 2 [forename] => Samue [surname] => Williams [dob] => 17/08/1985 )
  11. How do i select a row from an array where the key =2? Sam
  12. now im recieving this error: Warning: implode() [function.implode]: Invalid arguments passed in C:\wamp\www\index.php on line 123 I cant get my results into a table. Sam
  13. Sorry, may have confused everyone, I have my sql query which gets entered into an array, but i have some php that is generating an md5 hash which i need to add to each row with the sql query before its entered into an array. So an example of my output would be; key code patientid patientforename patientsurname dob 0 23ur2384388fg84f834 NHS938383 Sam Williams 16/09/2010 I nearly have the table finished as well except i cant work out why the patient ID isn't getting included in the table, instead its just dumped on top; <table> <tr> <td width="16%"><strong>Array Key</strong></td> <td width="16%"><strong>Patient ID</strong></td> <td width="23%"><strong>Forename</strong></td> <td width="23%"><strong>Surname</strong></td> <td width="17%"><strong>DOB</strong></td> <td width="21%"><div align="center"><strong>Allocation</strong></div></td> </tr> <?PHP foreach ($ptdbResultsArray as $key => $row) { echo '<tr>'; echo '<td>'.$key.'</td>'; echo implode('<td>', $row) . "</td>"; echo '</tr>'; echo $key; } ?> </table>
  14. yes thast right i do, also i cant work out how to add the results to a table, i need to add a random code (rand()) to each row before its entered to the array as well. I have so far for the output; <table> <?PHP foreach ($ptdbResultsArray as $row) { echo '<tr>'; echo implode('<td>', $row) . "</td>"; echo '</tr>'; } ?> </table> But i still need to add a random code to each row before its in the array.
  15. Thanks thorpe/gwolgamott, but i need to add a key to the array for a link and also display the results in a table. I can't seem to work out how to add a key to yoru solution thorpe and also table the results, although i do like the method as it is far cleaner than what i have been using. Any ideas? Sam
  16. Afternoon All, I am trying to store the results of a sql query to a multidimensional array with a key. I have this so far but i am getting an offset warning when returning the results via a loop; Make the array: while ($ptdbRow = mssql_fetch_assoc($ptdbResult)){ $ptdbResultsArray = array(array($ptdbRow['patientid'], $ptdbRow['forename'], $ptdbRow['surname'], $ptdbRow['dob'])); } Results: for ( $row = 0; $row < 4; $row++ ) { for ( $column = 0; $column < 4; $column++ ) { echo '|'.$ptdbResultsArray[$row][$column]; } echo '|<br />'; } Any help appreciated. Thanks Sam
  17. Have you looked at the mail() function within php? Or is their a specific reason for using smtp?
  18. Is there a reason why you wouldn't want to use cookies? Mobile devices? Anyway you could post the data to one page store it in an array and the simply post the data onwards or even pass it through the url and use the $_GET[] function obtain it. Say if you had three files your form.html, middle.php and confirm.php and you wanted to pass the data all the way to the end without a session then it may look like this. So form.html would pass the data to middle.php Then middle.php; <?PHP $forename = $_POST['forename']; echo "<a herf=\"http://yourdomain.com/confirm.php?forename={$forename}\">Next Step</a>"; ?> On this page you would construct a link that looked similar then when the use proceeds they pass the information through the url. Then confirm.php; <?PHP $forename = $_GET['forename']; ?> Please be aware that there are issues with this and you should sanitize your data before inserting to databases etc. Hope this helps. Sam
  19. Hi blmg911, What you are looking for is a UK Addressing Service. This may be of use to you; http://www.postcodeanywhere.co.uk/demos/addresses_uk.aspx This is one service amongst many that offer a lookup service for post codes ad provide relevant address to match. Like you mentioned these services do come at a cost and most will provide you with support for site integration. Hope this helps Sam
  20. Hi Rob, Have you looked at the cURLLib? http://curl.haxx.se/ I am sure you can achieve your goal with this or maybe look at the fopen() functions. Hope this helps Sam
  21. Hi All, I have been working on a project were by i want to extract data from a website and insert it into an array. I have got so far using the cURLlib to extract the table (which is a golf leader board). I have this http://www.prentongolfclub.co.uk/ept/ Now i know i need to use regex to clean the data and form the array but i a completely overwhelmed and don't know where to start. Can anyone offer me some advice or even better some coding example on how i can form an array from the table on that website. Thanks Sam
  22. ALL FIXED. I need to set the characterset of the webpage using a metatag. Sam
  23. Hi All, I have just created a script to grab a leader board from a website, but for some reason i am getting special characters appearing between forename and surname. How would i go about stripping these out. Below is the result and code. Thanks Sam <?php // lets rock $curl = curl_init(); // Set my url curl_setopt($curl, CURLOPT_URL, 'http://scores.europeantour.com/default.sps?pagegid={7991C900-B8A2-4C34-B856-343079885E16}&redirectorid=tournament_live&eventid=2010006&infosid=2'); // Curl to get headers //curl_setopt($curl, CURLOPT_HEADER, 1); // Tell it not to dump but store curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //go go go $data = curl_exec($curl); //im done curl_close($curl); //kind of crap but no other way to do it lets max the cpu for a split second. if (preg_match("/<div id=\"scoresBoard2\">(.*)<p class=\"printText\"/s", $data, $matches)) { echo $matches[1]; } ?> Current result set: http://www.prentongolfclub.co.uk/ept/
  24. Thanks Gizmola, Exactly what i was looking for.
  25. Morning Guys, Hope you are all well, I have been searching high and low for a solution for extracting leader board data from a golf website. Apologies if this may lead a little off topic but i am hoping that i can use php to solve my quandary. Each week on Europeantour.com from Thursday to Sunday they publish a live leader board on their website. I want a way to extract the leader board as it is or better still its raw data which I can then manipulate and place on a site of me own. I have searched high and low for rss/xml feeds which would make life easy but haven’t had much joy. Can anyone point me in the right direction? Many Thanks Sam
×
×
  • 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.