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!
  9. Alkimuz

    date_format

    wow, just move the date_format to the WHERE-clause!! thanks!!!
  10. Alkimuz

    date_format

    thanks for your help in the mean time, i also found an other solution, i didnt know the SQL-formulas MONTH() and YEAR() before ^^, probably there is still a lot faster way, but for now it works: <?php $datumresult = mysql_query("SELECT *, DATE_FORMAT(datum, '%m') as maand, DATE_FORMAT(datum, '%Y') as jaar FROM strip WHERE vlag = '0' AND datum = '$ID' LIMIT 1") or die ("could not execute paginaresult!"); $datumrow = mysql_fetch_array($datumresult); $m = $datumrow['maand']; $jaar = $datumrow['jaar']; if ($m <2){$vorigem = 12; $vorigej = $jaar - 1;} else {$vorigem = $m - 1; $vorigej = $jaar;} $vorigeresult = mysql_query("SELECT * FROM strip WHERE vlag = '0' AND MONTH(datum) = '$vorigem' AND YEAR(datum) = '$vorigej' ORDER BY ID DESC ") or die ("could not execute vorigeresult!"); $vorigerow = mysql_fetch_array($vorigeresult); ?>
  11. Alkimuz

    date_format

    perfect, but can you explain me how to do that?
  12. Alkimuz

    date_format

    ok, thanks! i am one stap further, but what if you dont know the date on forehand? for example, i take a random item and i want to select all items of the same month as this item, or all items of the previous month of this item? first i thought i could subtract the month number of the random item and select all items with the same month number or month number -1, but that would not be possible, like you say..
  13. i use the following for resizing to other size in pixels, you can change it a little to work for percentages (set in the main code the pixel size to, for example, 0.5 and define the new width and height in the function photoresize by multiplying the original width and height with this number) this code will mentain the aspect ratio and use the with as main resize variable and adapt height to that, you can play with the beginning of the function photoresize to change that. notice the "copy()" in the uploadscript in function.php: <?php function photoupload($filename, $source, $destination, $destination2) { /*START PHOTOUPLOAD*/ // Does the file have the right MIME type? if ($_FILES[$filename]['type'] != 'image/pjpeg' AND $_FILES[$filename]['type'] != 'image/jpeg' AND $_FILES[$filename]['type'] != 'image/gif' AND $_FILES[$filename]['type'] != 'image/png' AND $_FILES[$filename]['type'] != 'image/wbmp') { echo 'the file you want to upload is no photo, please go back to try again'; exit; } move_uploaded_file ($source, $destination ); copy($destination, $destination2); return 0; /*END PHOTOUPLOAD*/ } function photoresize($source, $maxx, $maxy)//foto wordt max breedte { /*START PHOTORESIZE*/ // Get current dimensions list($width_orig, $height_orig) = getimagesize($source); // Check if they are over their limit if ( ($width_orig > $maxx) || ( $height_orig > $maxy)) { if ($maxx && ($width_orig < $height_orig)) { $maxx = ($maxy / $height_orig) * $width_orig; } else { $maxy = ($maxx / $width_orig) * $height_orig; } // Resample voorbereiden $image_p = imagecreatetruecolor($maxx, $maxy); $image_type = strtolower( substr($source, strrpos( $source, '.' )) ); switch( $image_type ) { case '.gif' : $image = imagecreatefromgif($source); break; case '.jpg' : $image = imagecreatefromjpeg($source); break; case '.jpeg': $image = imagecreatefromjpeg($source); break; case '.png' : $image = imagecreatefrompng($source); break; case '.bmp' : $image = imagecreatefromwbmp($source); break; } // Resample de afbeelding imagecopyresampled($image_p, $image, 0, 0, 0, 0, $maxx, $maxy, $width_orig, $height_orig); // Output switch( $image_type) { case '.gif' : imagegif($image_p, $source, 100); break; case '.jpg' : imagejpeg($image_p, $source, 100); break; case '.jpeg' : imagejpeg($image_p, $source, 100); break; case '.png' : imagepng($image_p, $source, 100); break; case '.bmp' : image2wbmp($image_p, $source, 100);break; } } return 0; /*END PHOTORESIZE*/ } ?> in your main code: <?php @$picture = time().'-'.$_FILES['picture']['name']; @$filename = 'picture'; if ($_FILES['picture']['tmp_name'] == TRUE) { //photo uploaden $source = $_FILES['picture']['tmp_name']; $path= 'pictures/'; $destination = $path.$picture ; photoupload($filename, $source, $destination); //photo resizen $source = $destination; $maxx= '500'; $maxy= '500'; photoresize2($source, $maxx, $maxy); } ?> hope this helps!
  14. Alkimuz

    date_format

    hi, would like to select stuff on a specific month number and/or year where their date is stored as a DATE (0000-00-00), so i came up with this: $dateresult = mysql_query("SELECT *, DATE_FORMAT(date, '%m') as month, DATE_FORMAT(date, '%Y') as year FROM table WHERE month = '10' AND year = '2011' ") or die ("could not execute dateresult!"); but it seams not to work.. is it wrong to select on colums that are newly defined? if so, what is the right method? thanks!
  15. yeah, no problem, you should get the info from the link with $_GET[''], and than use that to look in your database again: $memberid = $_GET['lc_URL']; $result = mysql_query("SELECT * FROM playedgames WHERE memberid = '$memberid'"); while ($row = mysql_fetch_array($result)){ echo $row['gamename']; } EDIT: sorry, same solution as the one above me that dit post his answer a littlebit faster
×
×
  • 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.