Jump to content

fifin04

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fifin04's Achievements

Member

Member (2/5)

0

Reputation

  1. I do try with this tiny script and it's do the trick the only thing is the image is still having background colour so how can I remove the background colour and make it as transparent background here's the code //source jpeg image with white background colour it can be any colour as I assume $image = ImageCreateFromJPEG("bunnyjpeg_nottransparent.jpg"); header("Content-Type: image/png"); ImageJpeg($image, "mynewbunnypic.png"); ImageDestroy($image); hope someone will give me some shed on light on this... Thanks in advanced
  2. Hi all, I am currently making a website that has e-custom functions and a back end for the client. I want them to be able to upload images - but they need to be transparent. I do not want to leave this in the hands of the client, so I am looking at ways of using the GD library to make the change I got no issue with the png/gif type for upload/resize function since this type already transparent background but my major problems is how to deal with jpeg/jpg image type which is their background was not a transparent...so is it possible I can change/ convert to png/gif type upon successful of uploading image...so the new final image will be png/gif type with transparent background...is it doable...I am not even sure it is possible...? Thanks for any help..
  3. JAY6390-> Thanks for the class but FYI I'm using MSSQL Server as my database so as i can see in ur class it just for Mysql databases only...correct me if Im wrong.. ignace-> I've been playing with ur class but it seems the paging numbering not appear..or is it I missing something..the result looks like this..the 1st 20 records... B117646 B123851 B123940 B123939 B123938 B123937 B123936 B123920 B123935 B123934 B123933 B123932 B123919 B123931 B123930 B123918 B123929 B123917 B123916 B123913 paging numbering???????not appear... So hope u will shed me some light on this...sorry for silly questions..my code include("DataBase.class.php"); include("Paginator.class.php"); $db = DataBase::getInstance(); if($db){ $row = $db->executeGrab("SELECT * FROM ".PADU_NOTICE." WHERE DEPARTMENT_CODE='04'"); if($row){ $paginator = new Paginator($row, 20); $items = $paginator->getItemsForPage(1); foreach ($items as $item) { echo $item["NOTICE_NO"]."<br/>\n"; } } } Tq in advanced
  4. aii guys....really stuck up here...my attempt paginating my recordset no to avail...so far..I manage to get display the numbering for the total record as u can see here... somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 my desire just wanna display previous and next and next 10 record till reach total records as u can see here.. somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord somerecord previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 next after user click next it will display another 20 records previous 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 next and so forth.. Hope someone will shed me some light...here's the mockup illustration waht I after.. testpaging.php include("DataBase.class.php"); include("Pagination.class.php"); $db = DataBase::getInstance(); $row = $db->executeGrab("SELECT * FROM ".PADU_NOTICE." WHERE DEPARTMENT_CODE='04'"); if($row){ $numRows = $db->getNumRow(); if(isset($_GET['p'])){ $pg = $_GET['p']; }else{ $pg = 1; } $targetPage = $_SERVER['PHP_SELF']; $pager = Pagination::getInstance($row, $pg, $targetPage, 20,$numRows); if(is_object($pager)){ foreach($pager->__getPage($pg) as $item) { echo 'NOTICE NO :: '.$item['NOTICE_NO'].'<br>'; } echo "<br/>\n"; echo "<br/>\n"; echo "<br/>\n"; echo "<div align='center'>".$pager->__getNav()."</div>"; } } here's the paginationclass class Pagination{ static private $instance = false; public $_properties; public $pages; public $data = array(); public $_pageNum; public $_targetPage; public $_perPage; public $_nav; private $_numrows; private function __construct($data, $pageNum, $targetPage, $perPage, $numRows){ $this->_data = $data; $this->_pageNum = $pageNum; $this->_targetPage = $targetPage; $this->_perPage = $perPage; $this->_numrows = $numRows; $this->pages = array(); $this->buildPaging($this->_data); $this->buildNav(); } public static function getInstance($data=NULL, $pageNum=NULL, $targetPage=NULL, $perPage=NULL, $numRows=NULL){ if(!Pagination::$instance) { Pagination::$instance = new Pagination($data, $pageNum, $targetPage, $perPage, $numRows); } return Pagination::$instance; } public function __set($name, $value) { if(isset($name)) { $this->_properties[$name] = $value; } } public function __get($name){ if(isset($this->_properties[$name])){ return $this->_properties[$name]; }else{ return NULL; } } public function buildPaging($dataArr=NULL){ if(is_array($dataArr)){ $numberPages = count($dataArr)/$this->_perPage; if (round($numberPages)<$numberPages) { $numberPages = round($numberPages) + 1; } $k=0; for ($i=0;$i<$numberPages;$i++){ for($j=0;$j<$this->_perPage;$j++){ if(isset($dataArr[$k])){ $this->pages[$i][$j] = $dataArr[$k]; } $k++; } } } } /////////////////////////////portions printing the numbering////////////////////////////// //need help here.. public function buildNav(){ $this->_nav = ''; foreach($this->pages as $key => $page){ if($key == $this->_pageNum){ $style = ' style="font-weight:bold;text-decoration:none;color:#000;"'; } else { $style = ''; } $this->_nav .= '<a href="' .$this->_targetPage. '?page=' .$key. '"' . $style . '>' .$key. '</a> '; } } /////////////////////////////////////////////////////////////// public function __getNav() { return $this->_nav; } public function __getPage($num) { return $this->pages[$num-1]; } public function __clone(){ trigger_error("Clone is not allowed.", E_USER_ERROR); } } Hope someone will shed me some light..thanks you in advanced
  5. Hi..guys...jyst need some little help here...kind of stuck here...hope will get some help here...here's the scenario I have some array data retrive from textfile and has to do some schedule task agains dtbase data...so my problem is ...I can't find the solution to store the unmatch dt texfile agains db data store in others array and store the match data textfile in another array..let say's here... matchWithDBDTarray = array();-->store the data textfile match with db data notMatchWithDBDTarray = array();-->store the data textfile not match with db data here's the summary of all my pitfall... //some dummy data extract from DB $dbArrayData = array(array("A001","B"),array("A002","B"),array("A003","B"),array("A004","B"),array("A005","B"),array("A006","B"),array("A007","B"),array("A008","B"),array("A009","B"),array("A010","B"),array("A011","B"),array("A012","B")); //some dummy data extract from textfile $txtFileData = array(array("A001","B"),array("A002","B"),array("A020","B"),array("A021","B"),array("A022","B")); //start looping $txtFileData for($i=0;$i<count($txtFileData);$i++){ //using built-in php array fucntions array_walk($dbArrayData,"matchingWithDBData",$txtFileData[$i]); } function matchingWithDBData($valueDB,$key,$txtDtArr){ if($txtDtArr[0] == $valueDB[0]){ echo " <strong><font color='#FF9900'>MATCH</font></strong> <br/>"; //match data will save in matchWithDBDTarray }else{ echo " <strong><font color='#FF0000'>NOT MATCH</font></strong>"; echo $key." : DB = ".$valueDB[0]." || TXT = ".$txtDtArr[0]."<br/>"; //unmatch data will save in notMatchWithDBDTarray } } Hope someone will shoow me or give me some tips ..go on this...because the real db data sometimes it's about 1000..is ther any others solution to overcome this...really need help..as I struggle to it..tq in advanced..
  6. Hi there.. I really need help with my ugly regex code because it still can't diferrentiate string and string contain only numbers ok here the scenario; All the string must meet this 3 conditions 1.String contain only alpha,space and dot 2.String contain only alphanumeric,space and dot 3.String contain only numbers so here's my attempt code so far $testStringArray = array("abc. bc. def83","abc. bc.","123","567","fdg. qwe.","dfg. rtu. hu8"); //so i start filter testing here $total = count($testStringArray); for($i=0;$i<$total;$i++){ if(preg_match('/[a-zA-Z.\...\\s.]+$/',$testStringArray[$i])){ echo $i." : ".$testStringArray[$i]." contain only alpha,dot,space"; }else if(preg_match('/^[a-zA-Z0-9.\...\\s.]+$/i/',$testStringArray[$i])){ echo $i." : ".$testStringArray[$i]." contain only alpha,dot,numbers,space"; }else if(preg_match('/^[0-9]/',$testStringArray[$i])){ echo $i." : ".$testStringArray[$i]." contain only numbers"; } } Current output: contain only alpha,dot,numbers,space contain only alpha,dot,space contain only alpha,dot,numbers,space-->it seems the regex not wokr here contain only alpha,dot,numbers,space-->it seems the regex not wokr here contain only alpha,dot,space contain only alpha,dot,numbers,space suppose to : contain only alpha,dot,numbers,space contain only alpha,dot,space contain only numbers--->shoud be numbers only contain only numbers--->shoud be numbers only contain only alpha,dot,space contain only alpha,dot,numbers,space So i really need help with it....thanks in advance guys...
  7. Hi .. I just need ur expertise opinion guys...regarding my attempt to read the content of the texfile in everyline then push into array after going through some filtering process...my problem here is how to optimize this code since my code currently using substr to split the string in each line in order to seprated in different category...I hope u guys will show me the smart way how to loop the data in textfile...soryy for being such noob.. //here my php code [code=php:0] $pathtxt = "p151120091.jpp.txt"; //array to store data from textfile $record = array(); if ($fh = fopen($pathtxt, "r")){ while (!feof($fh)) { if ($dt = fgets($fh)) { $lines++; $pymt_location = substr($dt, 0, 4); $machine_no = substr($dt, 4, 2); $pymt_date = substr($dt, 6, ; $receipt_num = substr($dt, 14, 6); $revenue_code = substr($dt, 20, 4); $acc_no = substr($dt, 24, 14); $pymt_amount = substr($dt, 38, 10); $pymt_mode = substr($dt, 48, 1); $id_cashier = substr($dt, 49, 2); $cheque_no = substr($dt, 51, 16); //filter here if($revenue_code == "0020"){ array_push($record,array($pymt_location,$machine_no,$pymt_date,$receipt_num,$revenue_code,$acc_no,$pymt_amount,$pymt_mode,$id_cashier,$cheque_no)); } } }//end while //echo total record here echo count($record)." Total data in array after filter<br/>\n"; echo $lines." the sum of all data in textfile"; }else{ echo "can read textfile !!"; } and here are my sample textfile C07 41290420082138140020012400885359030000030365102 C07 412904200821381500202000370904019 0000004605102 C07 41290420082138160018D908211360402 0000013750102 C07 4129042008213817005110000437003 00000360008024539660002057167 C07 4129042008213818002010000669839 00000300008024539660002057167 C07 4129042008213819005030002379369 0000025700102 C07 4129042008213820005030002379330 0000095400102 C07 412904200821382100172000278403010 0000000855102 C07 412904200821382200172000278047012 0000004760102 C07 412904200821382300170000045738013 0000001025102 C07 41290420082138240016012400749311090000009330102 C07 4129042008213825005030006801066 00000275008024293132690537260 C07 4129042008213826005030006801066 00000270008024293132690537260 C07 4129042008213827005030002486126 0000009920102 C07 4129042008213828005030002340864 000004880030201323233 Hope will get most optimize way in order to loop the data in textfile..really need ur guys expertise opinion...tq..
  8. Hi guys... Actually I chunk out some data from txtfile and one of the data contains amount value but in string format like so.. "000000010000" -->desire result 100.00 "000000002000" -->desire result 20.00 "000000100050" -->desire result 1000.50 so how's the hell I can format the string so the end result will be 100.00 20.00 1000.50 any help are appreciated..TQ
  9. Thanks for the reply guys..I do get manage to solve it...only on matters of strtotime function only tq again
  10. Hi guy's... I'm totally lost here..because don't have any idea how to make a query for grab record using BETWEEN startdate and enddate since existing record are stored using this format datetime(dd/mm/yyyy hh:mm:ss) but my supplied $startdate and my $enddate are in this format date(dd/mm/yyyy) only....hope someone will shed me some light on this...is it possible to grab those record...?? //example of my query.. $sqlquery = "SELECT * FROM sometable WHERE OFFENCE_NOTICE_STATUS = 'A' AND CREATED_DATE BETWEEN ".$start_date." AND ".$end_date; //can't run this query because of the stored record in database are in different format datetime(dd/mm/yyyy hh:mm:ss) //my supplied variable in date(dd/mm/yyyy) format... Any help are appreciated TQ..
  11. Hi everyone...I just need help to look at my code why the AddCC function in phpmailer behave like AddBCC ..is it something wrong with my code...I got no issues with sending email because it run smoothly and nothing was wrong... only this portion curiousity question why is this AdCC function behave like AddBCC ....suppose to when Im sendign email using AddCC function the recipients should see others email add list in CC..but what happen now its empty...I mean it's not reveal the others email .. but the email was sent to everyone...eg:- the current situation happen when sendign using AddCC from = blala@c.com name = admin to = recipientemail@z.com cc = "blank here"!!! but the email was sending to everyone but not reveal here suppose to like this from = blala@c.com name = admin to = recipientemail@z.com cc = othersemail1@blabla.com,othersemail1@blabla.com,othersemail1@blabla.com, othersemail1@blabla.com, So below are my code include_once('class.phpmailer.php'); include_once("class.smtp.php"); $typeemail = $_POST['typeemail']; $subject = $_POST['subject']; $msg = $_POST['msg']; $cat = $_POST['cat']; $attachment = $_POST['attachstuff']; $mail = new phpmailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = "some host"; $mail->Mailer = "smtp"; $mail->Username = "some username"; $mail->Password = "somepassword"; $mail->FromName = "Admin"; $mail->From = "admin@blablabla.com"; $mail->Subject = $subject; $mail->Body = $msg; $mail->WordWrap = 65; $host = "localhost"; $dbuser = "someusername"; $dbpass = "somepass"; $dbname = "somedb"; $conn = mysql_connect($host,$dbuser,$dbpass); if (!$conn){ die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname, $conn); $sql="SELECT * FROM user WHERE category = '$cat'"; $result = mysql_query($sql)or die(mysql_error()); function fetch_all_array($query_string){ $out = array(); while ($row = mysql_fetch_array($query_string)){ $out[] = $row; } return $out; } $all_rows = fetch_all_array($result); $mail->AddAttachment("attachmentfile/".$attachment); foreach($all_rows as $key => $value){ //the format is correct the email was sendign to everyone but why it keep still un reveal the address huhuhu $mail->AddCC($value['email'],$value['name']); } if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; $answer = "0"; echo "answer=".$answer; } else { $mail->ClearAddresses(); $mail->ClearAttachments(); $answer = "1"; echo "answer=".$answer; unlink("attachmentfile/".$attachment); } mysql_close($conn); ?> Im end of my wit here...hope someone can give em some shed of light or at least point me ... Tq
  12. Hi there... Okay just a quick shoot....below are my currently table structure(MySql) to store the user birthday date idbirthday | name | birthdaydate -------------------------------------------------- 0 | user 9 | 22-05-2007 1 | user8 | 01-05-2007 2 | user4 | 21-07-2007 3 | user2 | 05-05-2007 So how to setup a mysql_query so that I can only print the record which is within current month eg;current month "MAY"..so the correct output will be 3 record...so I really need help on it....any help are appreciated....thank
  13. Hi there... just a quick shoot ...Okay I know very well how to get the record from databse directly..but now my application require me to output my record as xml output....so I really need help on it.../some guide ...this is what's my xml gonna be.... <?xml version="1.0" encoding="iso-8859-1"?> <calData> <event type="1" year="2007" month="05" day="23" timestart="8.00 am" timestop="10.00 am" title="urgent meeting" detail="some explaination here"/> <event type="1" year="2007" month="05" day="24" timestart="8.00 am" timestop="10.00 am" title="kickoff meeting" detail="some explaination here"/> <event type="1" year="2007" month="05" day="25" timestart="8.00 am" timestop="10.00 am" title="discussion" detail="some explaination here"/> </calData> and here are my field in my database(mysql) id | type | date | timestart | timestop | tittle | detail | ________________________________________________________________________ 1 | 1 | 25/05/2007 | 8.00 am | 10.00 am | discussion | blablabla | Hope someone will give me some shed on light on this...thanks in advanced....
  14. Hi nice people out there... Okay currently I'm working on my log system for my office use...so my purpose is just wanna seek advise/guide from php guru's here...the best/proper way to code this....Okay my problem is here...how to differentiate user level after the user success logging into the system....because what I'm working is now..I have 3 different page depends on user type after successing login...let's say I have this type of record in my dtbase... id | username | password | user_type | ____________________________________ 0 | user1 | pwd | director | 1 | user2 | pwd2 | sa | 2 | user3 | pwd3 | programmer| so the scenario is if the director login it'll redirect to "directorindex.php" page -and if sa succesing login into system it'll redirect to "saindex.php" page and so on... so I really need help on how to detect user_type after the login process because I want to redirect to the correct page....hope will get some shed on light on it... thanks in advanced
  15. Hi php guru's out there.. just need a little help here with my paging code...okay the code below are the code what I have currently and it works great... <? [b]//on the top of my page[/b] ////////////////////////////////////////////////////////////////////// include("dbconnect.php"); ///////////////recordset//////////////////////////////////////////// //////FORMATTING RECORDSET/////////////// $rowsPerPage = 10; $pageNum = 1; if(isset($_GET['page'])){ $pageNum = $_GET['page']; }//end if $offset = ($pageNum - 1) * $rowsPerPage; $query = "SELECT * FROM tshirt "; $pagingQuery = "LIMIT $offset, $rowsPerPage"; $result = mysql_query($query . $pagingQuery) or die('Error, query failed'); ///////////////////////////////////////////////////////////////////// [size=18][b]//at the bottom page [/b][/size] $result = mysql_query($query) or die('Error, query failed'); $numrows = mysql_num_rows($result); $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; if ($pageNum < $maxPage){ $page = $pageNum + 1; echo "<a href=\"$self?page=$page\">Next</a>\n"; } echo "$pageNum of $maxPage"; if ($pageNum > 1 && ($pageNum <= $maxPage)){ $page = $pageNum - 1; echo "\n\n\n<a href=\"$self?page=$page\">Previous</a>\n"; } ?> So the code will paging like this... next 1 of 5 previous ---->which is okay for a small amount of records but is so annoying for a big amount record because the visitor has to click fo multiple times in order to navigate for particular record...imagine if I have a thousand record...??So what I after is is there possible I can alter my code so that I can output like this for a big amount record... next 1 2 3 4 5 6 7 8 9 previous hope someone will give me some shed on light on how to achieve it.... thanks in advanced http://www.bundlecollections.net/paging/paging.zip
×
×
  • 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.