Jump to content

Alkimuz

Members
  • Posts

    45
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Alkimuz's Achievements

Member

Member (2/5)

0

Reputation

  1. Like Davey says, i am not going to search your whole code.. but if the questions are in an array, you could use the function shuffle() http://php.net/manual/en/function.shuffle.php
  2. you can use html in the content of the e-mail by adding the following headers: // To send HTML mail, the Content-type header must be set $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; cant help you with the multiple attachments, my knowledge is limited
  3. my end goal is to show an invoice with data of the customer, therefor i made a templatefile with pure html and within a function, i get the content of the templatefile and replace specific words in the templatefile with the data of the customer. so far so good. but now, i have a repeatitive part of the templatefile, the one with the bought items.. my idea is to substract that specific part out of the variable with the content of the templatefile, duplicate and fill it with a while loop and put it back in the variable, replacing the original.. (hopefully your still with me?) this works: $url = $_SESSION['dir'].'php/invoice.php'; $invoice = file_get_contents($url); //replace data $replacement = array("name", "prefix", "ordernumber", "orderdate", "address", "zipcode", "place", "country", "ordername", "orderaddress", "orderzipcode", "orderplace", "ordercountry"); foreach ($replacement as $word){ $invoice = str_replace('{$'.$word.'}', $data[$word], $invoice); } so the whole invoice code is in $invoice and the data of the customer is allready in it now time for the next step: the substraction of the specific part, which is between these tags: <!-- repeat --> <!-- /repeat --> i was thinking of: preg_match("/<!-- repeat -->(.*)<!-- \/repeat -->/", $invoice, $invoicepart); but that does not work.. is that because the syntax is wrong or because the part to select excists of a lot of html code? after that, i was think of: $itemresult = item_query(); while ($itemrow = mysql_fetch_array($itemresult)){ //replace item data $temporalpart = $invoicepart; $replacement = array("itemname", "itemamount", "itemprice", "itempricetotal"); foreach ($replacement as $word){ $temporalpart= str_replace('{$'.$word.'}', $itemrow[$word], $temporalpart); } $newinvoicepart.= $temporalpart } $invoice = str_replace("$invoicepart", "$newinvoicepart", "$invoice"); would that be the right way to go further? many thanks for helping me!
  4. awesome, i didn't know this kind of variable handling in SQL, thank you! for now, my question is kind of answered, as i will use your suggestion, although i was also curious if there is some kind of "standard" way to handle with database prefixes in coding; unfortunately, i am not advanced enaugh to figure out how the major CMS-systems are doing it, but for now, i am happy
  5. hi, i was wondering what an easy and right way would be to use a variable that can stand before the names of your tables. I've seen that a CMS like joomla or wordpress calls this a 'database prefix' what does work is for example: [config.php] $prefix = 'prefix_'; [index.php] $table = $prefix.'tablename'; $tableresult = mysql_query("SELECT * FROM $table") or die ("could not execute tableresult"); but i gues there should be a better way, as it looks kind of silly to declare the $table every time before the actual query.. thanks for any help!
  6. hmm.. i think more and more that it is indeed a server-issue.. i'll contact my hoster..
  7. maybe a stupid reply, but dit you think of looking into the spam-folders? the email might not come through the spam-filters of yahoo and gmail.. making the email more personal might help..
  8. Hey, i'd like to extract filenames from my database and present them as a downloadable zip-file to my users. I found a usefull function on http://davidwalsh.name/create-zip-php and thought i could work that out to my needs, but on this function itself (before using it), i get an error.. on the following line: if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { i get: Parse error: syntax error, unexpected ')', expecting '(' i dont get it, dont think there is actually an error in the function.. does it mean that the php installed on the server i use, cant handle this function or anything? my phpinfo: http://dwarsfluit.davidvandiepen.nl/test.php the function is: <?php /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } }?> thanks for helping!
×
×
  • 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.