Jump to content

rfeio

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rfeio's Achievements

Member

Member (2/5)

0

Reputation

  1. Hummmm... I think I know how to solve this: $merge = array(); for ($i=0; $i < $max_num_arrays; $i++) { $merge = array_merge($merge, $array[$i]); }
  2. Yeap, DJ Kat's solution seems a good one. Now, how can I solve my other problem? I don't know how many arrays I have to begin with in order to merge them in one single array. My idea was to create a variable with the arguments for the array_merge() function like: for($i=0; $i < $max_num_arrays; $i++) { $arguments .= '$array['.$i.'],'; } and then: array_merge($arguments) But this doen's work because $arguments is a string and not an array. Any ideas?
  3. Just to explain the objective of this exercise: The idea is to check the values that are common to all the arrays. For example let's suppose that: array[1] has the values (a, b, c, d, e) array[2] has the values (a, e, f, g, h) array[3] has the values (e, f, g, h, k) The end result should be 'e' which is common to all the 3 arrays. Now one of the challenges is that I don't know how many arrays I will have in the beginning. In this example it was 3, but it can be more or less then that. Any ideas?
  4. Hi! I have this script that generates a multiple array: array[x][y] Depending on the user input the array can be 'x' can be 1 or more. I want to use the array[x] with the array_intersect as in array_intersect($array[0], $array[1], ...) So I thought of doing: for($k=0; $k < count($array); $k++) { $temp .= '$array['.$k.'],'; } and then issuing: array_intersect($temp) but obviously it doesn't work. So my question is, how can I do this? Cheers!
  5. Mates, thanks a lot for your help!!! I have found the problem thanks to you johnsmith153. I have tried your code and I realized that the path was wrong! The "file_exists($path)" code warned me of the problem. I had to include in the path the "http://localhost" reference in order to read the file.
  6. Hi, I'm trying to implement a script where when a user clicks a link he gets a PDF file to open or save. In my index.php page I have the following link: <a href="http://localhost/example/get_file.php">Click here to get the file</a> And the script is in get_file.php: <?php $path = '/docs/document.pdf'; $mm_type="application/pdf"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . $mm_type); header("Content-Length: " . filesize($path) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary"); readfile($path); exit(); ?> Unfortunately it's not working properly. When clicking on the link and either selecting 'open' or 'save' from the dialog box, the end result is always the same; the end file is about 1KB in size when originally it was 456KB and therefore it's damaged. Any ideas on why this is happening? Thanks!
  7. For future reference; I've managed to solve this problem and I've posted the solution in my blog at: http://www.ruifeio.com/2009/06/30/php-session-not-being-from-site-to-wordpress/
  8. Default $_SESSION variable from site not being pased to WordPress Hi, I have installed WP to be part of my existing website. I now have the need to pass $_SESSION variables to WP from the site, but for some reason I'm being unable to accomplish this. Some more info: - I have Register Globals turned off - I've put session_start() on wp-config.php still, the $_SESSION variables don't work... Sad Here's a strange thing; locally when I specify in index.php: session_start(); echo "value= ".$_SESSION['test']; Everything works fine and I can pass values from the site's scripts into WP. When doing exactly the same thing on a real server, it doesn't work. The $_SESSION values seem to be killed? Please, help! Edit/Delete Message Reply With Quote Multi-Quote This Message Quick reply to this message
  9. rfeio

    PDF Parser

    Thanks guys! dgoosens, for the look of the site you've mentioned it looks more like converting the html into PDF. What I would need would be the opposite I think. bluejay002, are you referring to HTML tags? That wouldn't suit me since I would like to be able to search the content of the PDF files.
  10. Hi, My site has several PDF documents that users can download. However, I would like to be able to index the content of those pdf files, so that the users could do a search for a given argument, and the site would return which pdf files would be relevant. I was thinking that maybe the best way of doing this would be by parsing the content of the pdf files and save it on a MySQL table. When the user would do the search, the script would look in the table and return the pdf file names relevant for the search. I would need some guidance on how I could parse a PDF file since I've never done this before. Also, would this be the best way of achieving what I want? Thanks! Rfeio
  11. Hi, I would appreciate any help anyone could give me on this subject. I need to create a script that does: 1. Upload files (allowed formats): PDF, Word Doc, RTF, JPG, GIF, BMP 2. Validate that the file format uploaded corresponds to the ones allowed 3. Search inside PDF, Word Doc and RTF files. I'm ok with uploading the files, but I don't know how to validate their formats and how to do a search inside a PDF, DOC or RTF file. Cheers, R
  12. The solution is to do: $xml -> TransactionList[$i] -> TransactionID;
  13. Hi, I have the following XML: <NewDataSet> <TransactionList> <TransactionID>272201222</TransactionID> <TransactionDate>2008-12-31T11:05:00+00:00</TransactionDate> <SaleValue>3.3900</SaleValue> </TransactionList> <TransactionList> <TransactionID>274879519</TransactionID> <TransactionDate>2009-01-13T14:40:00+00:00</TransactionDate> <SaleValue>19.9900</SaleValue> </TransactionList> </NewDataSet> I would now like to create an array with this info. For that I have come up with the following code: $count = count($xml -> TransactionList); echo '<br><br>Total records = '.$count; for($i=0; $i < $count; $i++) { $transaction_id[$i] = $xml -> TransactionList -> TransactionID; $transaction_date[$i] = $xml -> TransactionList -> TransactionDate; $sale[$i] = $xml -> TransactionList -> SaleValue; } The problem is that the array always gets the data from the first record. When I print the array I get: Total records = 2 Record #1: Transaction id= 272201222 Transaction date= 2008-12-31T11:05:00+00:00 Sale= 3.3900 Record #2: Transaction id= 272201222 Transaction date= 2008-12-31T11:05:00+00:00 Sale= 3.3900 What am I missing? How can I load all the records on the XML to the array? Cheers!
  14. Ok, I've found the solution for the problem. The idea was to be able to load from table the subcategories that had been selected and mark them as checked on the checklist. All the code was already in place (see previous messages) and what was missing was to loadm from table and feed the $subcategory array that is used in the checklist. Here's the missing code: $select = "SELECT subcategory_id FROM selected_products WHERE (merchant_id = '$merchant_id') ORDER BY subcategory_id"; $query = mysql_query($select); $subcategory = array(); $i = 0; //Resets counter while ($record = mysql_fetch_array($query)) { $subcategory_id = $record["subcategory_id"]; $subcategory[$i] = $subcategory_id; //Loads record into array $subcategory $i++; //increments counter } //ENDS while ($record = mysql_fetch_array($query))
  15. Hi! Here's the thing; I have a MySQL table that contains the catagories and subcategories indexes for products. Example: Product Category_id Subcategory_id 1 3 11 1 2 5 2 1 2 To create a selectable checklist, where a list of all the categories and subcategories is listed, I've coded: $select = "SELECT * FROM list_categories ORDER BY category"; $query = mysql_query($select); while ($categories = mysql_fetch_array($query)) { $category_name = $categories["category"]; $category_id = $categories["category_id"]; $select2 = "SELECT * FROM list_subcategories WHERE (category_id = '$category_id') ORDER BY subcategory"; $query2 = mysql_query($select2); echo '<li>'.$category_name; echo '<ul>'; while ($subcategories = mysql_fetch_array($query2)) { $subcategory_name = $subcategories["subcategory"]; $subcategory_id = $subcategories["subcategory_id"]; echo '<li>'; echo '<input type="checkbox" name="subcategory['.$category_id.'][]" value="'.$subcategory_id.'"'; echo ((count($subcategory) <> 0) and (in_array($subcategory_id,$subcategory))) ? 'checked' : ''; echo '/>'; echo $subcategory_name; echo '</li>'; } //ENDS while ($subcategories = mysql_fetch_array($query2)) echo '</ul>'; echo '</li>'; } //ENDS while ($record = mysql_fetch_array($query)) When I select the categories/subcategories from the checklist then this info is stored on a table: $categories_list = $_POST["subcategory"]; foreach ($categories_list as $category => $subcategories) { foreach ($subcategories as $subcategory) { $insert = "INSERT INTO selected_products (product_id, category_id, subcategory_id) VALUES ('$product_id', '$category', '$subcategory')"; mysql_query($insert); } //ENDS foreach ($subcategories as $subcategory) } //ENDS foreach ($categories_list as $category => $subcategories) This all works fine and I'm able to store the selections. Now, what I need to do and so far I haven't been able to is to get the info from the table and pre-select the checkboxes that I have chosen before and kept record on the table. Any ideas? Thanks! Cheers.
×
×
  • 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.