Jump to content

maca134

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Everything posted by maca134

  1. Hey If i understand you correctly, this one it easy. I would save the filename in a var first: $filename = $value . '_' . str_replace('/', '', $data[$ccyValue][0]) . '.csv'; $filename = strtoupper($filename); $fp = fopen(DIR . $filename, 'w'); Thats should work
  2. Hey all Im trying to find a way to combine images but set the blend mode, like in Photoshop, selecting how layers are blended together. I have looked at all the docs for GD with no luck... Cheers in advanced Maca134
  3. you will have to draw the table if you use the PHP image functions. Finding a "HTML -> PDF" PHP is going to be much easier. try looking on www.phpclasses.org, its a great website for PHP classes
  4. Oh i use codeigniter all the time... Its easy to integrate it into a controller class Home extends Controller { public $item_count = 0; ...your other vars/controllers/etc... function _scan( $parent_cat_id = 0 ) { $result = mysql_query('SELECT * FROM `cats` WHERE `parent_id` = "' . $parent_cat_id . '"'); if ( mysql_num_rows($result) > 0 ) { $item_count = $item_count + mysql_num_rows($result); while ( $row = mysql_fetch_assoc($result) ) { $this->_scan( $row['id'] ); } } } function _get_item_count() { return $this->item_count; } } Or you could put the function into a Model, which would make sense, as they are for DB stuff
  5. You could embed the image data directly into the HTML page, take a look at this: http://danielcamargo.com/blog/embedding-image-in-html/ <div class="some_image" style="width:100px; height: 100px; background: url(data:image/gif;base64,<?php echo base64_encode($image_data_gif); ?>);"></div>
  6. Hey assuming you have an open database connection, the code below might be suitable: class recursive_scan { public $item_count = 0; function scan( $parent_cat_id = 0 ) { $result = mysql_query('SELECT * FROM `cats` WHERE `parent_id` = "' . $parent_cat_id . '"'); if ( mysql_num_rows($result) > 0 ) { $item_count = $item_count + mysql_num_rows($result); while ( $row = mysql_fetch_assoc($result) ) { $this->scan( $row['id'] ); } } } function get_item_count() { return $this->item_count; } } $rs = new recursive_scan; $rs->scan(); var_dump( $rs->get_item_count() ); I have tested it but it should work
  7. Cheers I was having a dumb moment lol
  8. Hey Im trying to set some vars in a class, here is code: class someClass { public $var1 = ''; public $var2 = ''; public function __construct($options) { if (isset($options) && is_array($options)) { foreach ($options as $key => $val) { $this->$$key = $val; } } } } $options = array('var1' => 1, 'var2' => 2); $class = new someClass($options); I know the above is wrong but can someone tell me how to access class vars, like you can access vars with a double dollar sign ($$vars) Thanks in advanced
  9. The best thing for you to do is re-write, putting the code on 'more than one line' It would of made the error easier to spot( line numbers are given on errors) The code would be a nightmare for you to maintain later on... But a quick look suggests theres missing quotes all over the show and some that havent be slashed out... So i suggest re-write (im sure you really dont want to tho)
  10. mysql_fetch_assoc is the function you require http://php.net/manual/en/function.mysql-fetch-assoc.php
  11. thats is because the function mysql_fetch_array() outputs an array. Try var_dump($output) and see what happens
  12. you need to make sure the fetch_array function is in the class. also i good idea to output the SQL instead on executing it to check it right. Might be an idea to remove the 'at' at the end of mysql_query(), if the SQL is correct then it wont produce an error.
  13. After the line 'public $ini;' Put 'private $query;' and the last line of the dbselect function change from $query = @mysql_query($q); to $this->query = @mysql_query($q); Now you can create another function like so: public function fetch_array() { return mysql_fetch_array($this->query); } This will return the results you after
  14. The last line of the function needs to be something like $this->query = @mysql_query($q); Then $row = mysql_fetch_array($this->query) will work if the line is inside a function in the same class as the function 'dbselect'
  15. Take a look at this: http://www.phpclasses.org/browse/package/1267.html
  16. Heres a little example of how it works: <?php // Setting simple multi-array up $someArray['a']['1'] = 'cell: a1'; $someArray['a']['2'] = 'cell: a2'; $someArray['a']['3'] = 'cell: a3'; $someArray['b']['1'] = 'cell: b1'; $someArray['b']['2'] = 'cell: b2'; $someArray['b']['3'] = 'cell: b3'; $someArray['c']['1'] = 'cell: c1'; $someArray['c']['2'] = 'cell: c2'; $someArray['c']['3'] = 'cell: c3'; // Converts the array into a JSON string $json_string = json_encode($someArray); ?> <html> <head> <title>JSON Example</title> </head> <body> <script type="text/javascript"> var someArray = <?php echo $json_string; ?>; /* Sets someArray */ /* Examples: Access the array in JS */ document.write('someArray[\'a\'][\'1\'] = ' + someArray['a']['1'] + '<br />'); document.write('someArray[\'b\'][\'2\'] = ' + someArray['b']['2'] + '<br />'); document.write('someArray[\'c\'][\'3\'] = ' + someArray['c']['3'] + '<br />'); </script> </body> </html>
  17. do you want to embed the image into the email or link it?? to link it, all you need to do is file_put_contents() to a lcation that is accessible to the web then link the image in the email "<img src='http://www.yourdomain.com/path/to/img' />" Embedding the image increase bandwidth on the server especially if your sending loads of emails. The best thing to do for embedding is take a look on www.phpclasses.org and find a mime email class, will make your life much easier
  18. have you tried using json_encode?? You could probably echo the resulting string into the page <script type="text/javascript"> var myJSONObject = <?php echo json_encode($this_array); ?>; </script>
  19. If its already image binary data then you shouldn't need to use imagecreatetruecolor. Eg. If the binary data is a GIF header('Content-type: image/gif'); echo $binary_data; exit; That should do it
  20. found this: http://www.zend.com//code/codex.php?ozid=175&single=1 Slightly edited it: class dec2fraction { function convert($number, $top_heavy = false) { if (strpos($number, '.') === false) $number .= '.0'; list ($whole, $numerator) = explode ('.', $number); $denominator = 1 . str_repeat (0, strlen ($numerator)); $GCD = self::GCD($numerator, $denominator); $numerator /= $GCD; $denominator /= $GCD; if ($top_heavy) { $numerator = $numerator + ($whole * $denominator); $whole = 0; } return array('whole' => (int) $whole, 'numerator' => $numerator, 'denominator' => $denominator); } function GCD ($a, $b) { while ( $b != 0) { $remainder = $a % $b; $a = $b; $b = $remainder; } return abs ($a); } } var_dump(dec2fraction::convert(3.14, true)); var_dump(dec2fraction::convert(3.14, false)); var_dump(dec2fraction::convert(3, true)); var_dump(dec2fraction::convert(3, false)); var_dump(dec2fraction::convert(5.25, true)); var_dump(dec2fraction::convert(5.25, false)); /* OUTPUT array 'whole' => int 0 'numerator' => int 157 'denominator' => int 50 array 'whole' => int 3 'numerator' => int 7 'denominator' => int 50 array 'whole' => int 0 'numerator' => int 3 'denominator' => int 1 array 'whole' => int 3 'numerator' => int 0 'denominator' => int 1 array 'whole' => int 0 'numerator' => int 21 'denominator' => int 4 array 'whole' => int 5 'numerator' => int 1 'denominator' => int 4 */ Hope this helps
  21. so do you want the follow: 1.5 -> 3/2 or 1 1/2 2.2 -> 11/5 or 2 1/5 ??
  22. If your going to run some PHP script using Lynx/wget, I dont think you need the '#!/usr/local/bin/php' at the top You only need this if you want to run the script directly from the command line. I use NANO to edit '/etc/crontab' and use WGET to run the script. The script be a normal php file that 'can' be run from your browser. 00 00 * * * root wget -O /dev/null http://www.somedomain.co.uk/cronjobs/daily_jobs.php /dev/null 2>&1 Runs daily @ 12:00am This work a treat for me. Hope it helps!
×
×
  • 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.