PHP - Colorize Based On Value
Hello folks. I have a system showing stock of products. Now I want to colorize the value based on how much it is.
For example 0 is red and then green is 10 000 and up. So the range should be like a smooth gradient. What's the algorithm? Similar TutorialsI'm wondering if the GD library is capable of coloring ONLY the non-transparent areas in an image. I had this image white, black, and every other color under the moon, but could only get GD to color the entire canvas (width and height) of the image with an opacity over it. I'm merging many layers on top of each other so I can't afford to color the entire square and lower the opacity and do some weird multiply stuff.
That's the image above. Then I have some lineart, markings, eye color, etc. So I had all my possible colors white areas that I layer on top of eachother. I want to color the entire non-transparent areas with a color (dynamic).. so I can't just color it in Photoshop and then upload it or else I would literally have millions of possibilities for every single color and shade..
Thanks for any help. I was trying to go with ImageMagick if GD isn't capable, but I can't even get that downloaded in my Wamp. I'm using 64 bit Wamp so I have no idea if that does something or whatever. I can get it installed on my computer and run it via command line, but I can't get it to work and render images in my Wamp files... can't ever find a .dll that works.
hi everyone. i need to figure out how to display one tr or another based on if N/A appears in one of the TR's. if i use: 'if ($result['NoChargeFile'] = 'N/A')' it repeats N/A for all rows. if i use: 'if ($result['NoChargeFile'] = N/A)' only the TotalFees TR is displays. What i need to do is display the TOTALFEES if the NOCHARGEFILE is not N/A. If NOCHARGEFILE is N/A, display N/A instead of the TOTALFEES. Any ideas how to fix this issue? thanks. Code: [Select] <?php echo "<table width='100%' border='0' cellpadding='1'>"; $string = $string."$pages->limit"; $query = mysql_query($string) or die (mysql_error()); $result = mysql_fetch_array($query); if($result==true) { do { echo "<tr>"; echo '<td nowrap>' . $result['CompanyName'] . '</td>'; echo '<td nowrap>' . $result['CompanyReferenceNumber'] . '</td>'; if ($result['NoChargeFile'] = 'N/A') { echo '<td nowrap>' . $result['NoChargeFile'] . '</td>'; } else { echo '<td nowrap>' . $result['TotalFees'] . '</td>'; } echo '<td nowrap>' . $result['DateRecorded'] . '</td>'; echo '<td nowrap>' . $result['DateClosed'] . '</td>'; echo "</tr>"; } while($result = mysql_fetch_array($query)); } // close table> echo "</table><hr>"; ?> I figured it out. i need == not =. I have a page where I want a success and a fail response. It's a contact page so, if they fill in all that's required, and send, a success "message" will pop up but if they send but for some reason, it fails, to display a fail "message". What it does right now is the fail and success are constantly visible regardless. So how do I make it display the corresponding message accordingly? *Also how am I to make the text within the boxes invisible ? But that's lower priority I have this array: Code: [Select] Array ( [jan] => 2 [feb] => 1 [mar] => 2 [apr] => 1 ) ..and I want to return: Code: [Select] Array ('jan', 'mar') As in, find the 2 elements with the highest count and put them in an array. What is the simplest way to achieve this? Hello. I want to make a web-based rpg with mysql and php but need alot of help, I tryed once and failed. Please msn me: cginbarrhaven@hotmail.com I need LOTS of help. Im stuck! Zeroth Hi, I need to create a secure API at work so that 2 systems can interact with each other and request data (json format). I need to use an API key for this but don't want to use an API key stored in a database, what is the best way to go about this? I would like to use some sort of encryption algorithm and a white list of a few values to validate against once decrypted, is this safe and are there any algorithms I can use to generate my keys and white list? Hi all, Relitively new to PHP but am trying to code a site that dynamically creates urls using Joomla CMS. Basically I'd like a div to show on pages' url starts /component/.... but hide it if not. The urls of the pages on which the div is to be hidden start /index.php?. I've tried Code: [Select] <?php if (strpos($_SERVER['REQUEST_URI'], 'component') > 0) { echo '<div id=\"stuffdiv\">stuff</script></div>';} ?> only issue is... its always fasle hence the div never shows. If i replace > with >= its always true, and appears on all pages, even those not containing 'component'... Can someone tell me if this should work or if Im being really stupid? Thanks in advance! Tom This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=359538.0 Hello guyz, Well i am storing some files on my server, i want only members to be able to download files. these are what i want to do : I should have an initial URL like this : "http://mysite/file/{file_id}/filename.mov so i will be checking to see if member is logged in, if yes then it should generate a temporary id which will expire within 1 day and start the download automatically! I have coded the user class which checks if its logged in, and i am generating the id, but the problem is how to show the final file url like this : http://mysite/file/{sha1 or something very random}/filename.mov and let it to be downloaded. thanks I am developing a page that displays info from a database based on a variable called "ID". On this page is a form that when submitted runs an external function file to first error check the form and then insert it into the database. The problem i'm having is if i include the page which had to form to display the error message on, it doesn't load the right info from the database because its not loading based on the ID. So is there an alternative way to write: include ("toDo.php?ID=".$ToDoID); Any help is much appreciated. I have htaccess file from which I am calling htpasswd. Currently its ask for authentication from everyone. I want it IP based or Domain based so that a user requesting from specific IP may not have to go through http authentication. Some domain calling the web pages in background like paypal OR google checkout can access the page without http authentication. Is it possible ? content of htaccess file is given below. AuthUserFile /var/www/web/.htpasswd AuthName "Authorization Required" AuthType Basic <Limit GET POST> require user username </Limit> Main URL of website home page: www.mysite.com and this shows image "A" in the header. I want to have a marketing campaign which will send people to my site via this link: www.mysite.com/index.php?ref=att When people get to my site via the 2nd link, I want to show image "B" instead of image "A". I put this at top of home page... Code: [Select] require_once("includes/session.php"); if (isset($_GET['ref']) && ($_GET['ref'] == "att")) { $_SESSION['ref'] = "att"; } else { } and this code is in my header include file, a little further down on the page... Code: [Select] <?php if (isset($_SESSION['ref']) && $_SESSION['ref'] == "att") { echo "<span class='phone'><img src='/images/B.png' /></span>"; } else { echo "<span class='phone'><img src='/images/A.png' /></span>"; } ?> Does this look right? because I can't get it to work. It's showing image A regardless of which URL I use. I have to be missing something obvious because I really thought this would be super easy to do. If anyone sees any problems, let me know. But I'll keep testing and hopefully find my mistake. Thanks! Good day: I am tryint to redirect back to a page based on non selection. I am using this code, it is redirecting but not passing the $aid variable on the url. The page is getting the passed variable before doing the redirect. Here is the code: Code: [Select] if ($_POST['hid']==0) { header('Location: sample.php?aid=."$aid"'); } Thanks in advance. Hi all, I'm wondering if it's possible to use the $numrows boolean parameter where $numrows = 0 and meets a condition. For instance, my code is set up to check for classes where $numrows>0 and then displays the classes. If $numrows < 1, it echoes a message saying there are no classes available and to call the training department. I would like to redirect one of the classes to another link by using a strpos function to search for the classname within the URL. As I understand it, I would have to embed it in the else part of the statement if it's at all possible. Here's what I have so far. if ($numrows > 0) { echo "<p align=\"left\" class=\"style2 style4\">Click in the check box next to the date for which you would like to register: </p>"; echo "<p align=\"left\" class=\"style2 style4\">" . $_GET['classname'] . "</p>"; echo "<table width=100% style=\"color:#FFFFFF\">"; echo "<th></th>"; echo "<th>Date</th>"; echo "<th>Time</th>"; echo "<th>Location</th>"; echo "<th>Instructor</th>"; while ($results = mysql_fetch_array($rs)){ echo "<tr>"; echo "<td><input type=\"radio\" name=\"checkbox\" value=\"" . $results['date'] . "|" . $results['time'] . "|" . $results['location'] . "|" . $results['instructor'] . "|" . $results['course'] . "\"" . "></td>"; echo "<td class=\"style11\">" . $results['date'] . "</td>"; echo "<td class=\"style11\">" . $results['time'] . "</td>"; echo "<td class=\"style11\">" . $results['location'] . "</td>"; echo "<td class=\"style11\">" . $results['instructor'] . "</td>"; echo "</tr>"; } echo "</table>"; } elseif (strpos($_REQUEST['classname'], "BloodBorne Pathogens Video")); { echo "Bloodborne Pathogens is exclusively offered online. Please <a href=../training/online_courses/Bloodborne/BB.html>click here</a> to take the course."; } else { echo "Please call the training department as there are no classes scheduled at this time." } Please let me know if this is even possible or if I'm off my rocker. I'm fairly new to the PHP world but not a newb Thanks a bunch for your time! hi, i am working on a project in school ( web based application ) that requires me to do the whole reservation pannel as in the website. i am trying to do something close to www.expedia.com ( on the left ). any ideas how to do it. i have done my database in php my admin and i use dreamweaver to create my forms as i connected my database to dreamweaver. any help how to do it on dreamweaver without using codes ?? appreciate any help. Hi all I am trying to write a piece of code that selects different products from the database based on the URL parameter. There are 3 fields; category, type and colour. My URL will look like this if there is all three selected: product.php?category=31&type=74&colour=3 Basically, if what ever is set in the url I need this to be selected from the database. Here's my code: if (!isset($_GET['category']) && !isset($_GET['type']) && !isset($_GET['colour'])){ $fetchproducts = mysql_query(" SELECT * FROM `products` "); $lightboxcount = 0; while($returnedProduct = mysql_fetch_array($fetchproducts)) { $lightboxcount ++; include('product-cell.php'); } } Although if there is no colour or the colour is blank like this: product.php?category=31&type=74&colour= I want it to select the items from the database just where the category and type are set. Please help! Many thanks Hi, I'm trying to get a working php script that will redirect visitors based on a number of variables. I first want to check the country the visitor is from, and redirect based on the user's country ip address. If visitor is not from the US, then go to google.com (for example)... but only after also checking some other variables. I want to also redirect any user (including US visitors) who are using a mobile device browser/cell phone, and redirect visitors coming from a Linux box. I'm not sure how to add those as if/else statement. Any help would be appreciated. Here's what I have so far... Geo ip Redirect: ------------------- <?php require_once("GeoIP.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code == 'US') { header('Location: http://www.google.com'); } else { header("Location: http://www.redirect.com"); } ?> Mobile Browser Redirect: ------------------------------ require_once('mobile_device_detect.php'); mobile_device_detect(true,false,true,true,true,true,true,'http://redirect.com',false); So not sure how to detect and redirect Linux users, and then how to link these all together in one script so it checks all variables before sending user to destination URL. Hope you can help. I really appreciate it! I assume this can be done somehow w/ PHP. How would I create a page which only displays based on detection of certain IP addresses and if the certain IP address is not detected, then redirects to a not allowed page. I have a list of the IP addresses to allow. Thanks in advance! Hello everyone, here is my problem. I am working for someone that would like users to be able to create a Trial Account on their website. This trial account is to be used for 24 hours, once the 24 hours is completed they can no longer login/use that account. Everything about the Trial Account is completed, other then the account timer. I am at a loss on how to get this part done. I was thinking that I would use the MySQL commands, GETDATE() and DATEADD(), to get the date and time that the account was created and using the DATEADD() command I would add 24 hours to the GETDATE() value. Then if the user logs into at a date past the DATEADD() value the Users Account type is switched to 3(This means that the account has been disabled) and then is directed to the Logout page, which then redirects him back to the homepage. After this point, the user can no longer login due to the code preventing any user with an account type of 3 to login. The problem is that I am unaware how to incorporate the GETDATE() and DATEADD() functions into my PHP code. Would anyone be able to explain how I can get this done, or suggest a better method of inputting a starting time and ending time for the account? Thank You for any/all help. Hi guys, PHP advanced amateur and PHPFreaks newbie here. I have a problem with some code I've written. What the code is supposed to do, is take in 15 records in a single MySQL table column, and then print them out in a format like this: 1 2 3 4 5 6 7 8 9 so on so on. Here is the page in question: http://robbieduggan.com/strawberry-interactive/portfolio-web-design.php Now the problem is, you can see 14 images there, but it seems to be negating the first one. Its always whatever row 0 is, because if I change the SORT BY attrabute in the code below, it's a different one that is missing. Here is my code to get the data: mysql_select_db($database_strawberry, $strawberry); $query_rsProjects = "SELECT page_unique_identity, clean_title, thumbnail FROM tblprojects ORDER BY `timestamp` DESC"; $rsProjects = mysql_query($query_rsProjects, $strawberry) or die(mysql_error()); $row_rsProjects = mysql_fetch_assoc($rsProjects); $totalRows_rsProjects = mysql_num_rows($rsProjects); And here is the code to create the table: echo "<table width='100%' border='0' cellspacing='5' cellpadding='5'>"; for($i = 0; $i < $totalRows_rsProjects; $i++) { $row = mysql_fetch_array($rsProjects); if($i % $columns == 0) { echo "<tr>"; } echo "<td>"; if($row['page_unique_identity'] != NULL){ echo "<a href='website-details.php?project=".$row['page_unique_identity']."'><img src='portfolio/".$row['thumbnail']."' alt=".$row['clean_title']." width='267' height='162' /></a>"; } echo "</td>"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $totalRows_rsProjects) { echo "</tr>"; } } Thanks in advance for any help |