PHP - Color Mixer Script
I would like to add a color mixer (not a color selector) on a client's site. It would be like this one: http://www.dur-a-flex.com/Home/ColorPicker
Does anyone know where to find a script like this, or if they know a developer who could build it? Similar TutorialsThis is the php file code to a video jukebox add-on script, for a popular web video script. I'd like to modify it so the "Click Here" text font and color can be changed. Can you help or suggest what I can do to accomplish this? Thanks Code: [Select] <?php include("../classes/config.php");?> <artworkinfo> <? $query = "select * from videos where viewtime<>'0000-00-00 00:00:00' and public_private='public' AND approved ='yes' AND promoted ='yes' limit 10"; // Max 10!"; $db=mysql_connect ($dbhost,$dbusername,$dbpassword) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($dbname); $num_rows = mysql_num_rows(mysql_query("select * from videos WHERE public_private = 'public' AND promoted = 'yes' AND approved ='yes'")); $result = mysql_query($query) or die ('Query Error: ' . mysql_error()); while ($results = mysql_fetch_array($result)) { ?> <albuminfo> <artLocation>../uploading/thumbs/<?=$results['video_id']; ?>.jpg</artLocation> <artist>Click Here!!</artist> <albumName><?=$results['title']; ?></albumName> <artistLink>../play.php?vid=<?=$results['indexer']; ?>&src=jukebox</artistLink> <albumLink>../play.php?vid=<?=$results['indexer']; ?>&src=jukebox</albumLink> </albuminfo> <? } mysql_close(); ?> </artworkinfo> Hello everyone! I need a little help to get functions names from the GD library. first i want to say i have a little knowledge with GD library like create image with words and etc. So , what i'm trying to do is to take image and than take the color of the first pixel on the top left than do some function work and than set this pixel on the top left to another color. now , i know how the algorithm should look like , i just don't know what function i need to use to: take specific pixel color from the image set new color for pixel on specific place i'll be glad if you could help me with that , regards , Mor. Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> hey guys im really just after a bit of help/information on 2 things (hope its in the right forum).
1. basically I'm wanting to make payments from one account to another online...like paypal does...im wondering what I would need to do to be able to do this if anyone can shine some light please?
2.as seen on google you type in a query in the search bar and it generates sentences/keywords from a database
example:
so if product "chair" was in the database
whilst typing "ch" it would show "chair" for a possible match
I know it would in tale sql & json but im after a good tutorial/script of some sort.
if anyone can help with some information/sites it would be much appreciated.
Thank you
I'm trying to use this script known as SimpleImage.php that can be found here <a href="http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php">link</a> I'm trying to include what is on the bottom of the page to my existing script can anyone help me I've tried several ways but its not working. Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $target_path = $image_folder.basename($filename); move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path); //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> Hello, I stored a fsockopen function in a separate "called.php" file, in order to run it as another thread when it needs. The called script should return results to the "master.php" script. I'm able to run the script to get the socket working, and I'm able to get results from the called script. I tried for hours but I can't do the twice both My master.php script (with socket working): Code: [Select] <?php $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; $result = exec($command); echo ("result = $result\r\n"); ?> and my called.php script Code: [Select] #!/mnt/opt/usr/bin/php-cli -q <?php $device = $_SERVER['argv'][1]; $port = "8080"; $fp = fsockopen($device, $port, $errno, $errstr, 5); fwrite($fp, "test"); fclose($fp); echo ("normal end of the called.php script"); ?> In the master script, if I use Code: [Select] $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; the socket works, but I have nothing in $result (note also that I don't anderstand why the ( ... &) are needed!?) and if I use Code: [Select] $command = "/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR]"; I have the correct text "normal end of the called.php script" in $result but the socket connection is not performed (no errors in php logs) Could you help me to find a way to let's work the two features correctly together? Thank you. im trying to get a row color coded by a $var that is pulled from mysql. if $val = yes the <tr> = green else red im only concerned with the table row color atm. the rest of the code is still wip relavent section of code <tr bgcolor= <?php "$bgc"; ?>> // this is were i want the $var placed <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $rows['make']; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['comments']; ?></td> <td> <?php echo $rows['sound']; ?></td> <td> <?php echo $rows['gfx']; ?></td> <td> <?php echo $rows['recovery']; ?></td> <td> <?php echo $rows['date']; ?></td> <td> <?php echo $rows['valby']; ?></td> <td width="41" align="center"><a href="update.php?id=<?php echo $rows['id']; ?>">update</a></td> <td width="36" align="center"><a href="delete_ac.php?id=<?php echo $rows['id']; ?>">delete</a></td> </tr> <?php // table bg colour $choice = strtoupper($rows['gfx']); if($choice == "PASS"){ $bgc = "#7FFF00" ; }else{ $bgc = "#8B8989" ; } } ?> full code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Modify DataBase</title> </head> <body> <p align="center"> </p> <table width="400" border="1" align="center"> <tr> <td TD BGCOLOR="#FF9900"> <?php include("config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $tbl_name="dsgi_serval"; // Retrieve data from database $search = trim($_POST['search']); if ($search == '' || $search == ' '){ echo "Search Field is Empty - Please Input an SKU Number!"; die; } else{ $sql="select * from $tbl_name WHERE sku LIKE '%$search%'"; $result=mysql_query($sql) or die (mysql_error()); } ?> </td> </tr> </table> <table width="800" height="72" border="1" align="center" cellpadding="3" cellspacing="0"> <tr> <td width="113" align="center"><strong>Orig SKU</strong></td> <td width="66" align="center"><strong>Recon SKU</strong></td> <td width="90" align="center"><strong>Make</strong></td> <td width="169" align="center"><strong>Model</strong></td> <td width="58" align="center"><strong>comments</strong></td> <td width="161" align="center"><strong>Sound</strong></td> <td width="66" align="center"><strong>Graphics</strong></td> <td width="90" align="center"><strong>Recovery</strong></td> <td width="169" align="center"><strong>Date</strong></td> <td width="58" align="center"><strong>Validated By</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr bgcolor= <?php "$bgc"; ?>> <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $rows['make']; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['comments']; ?></td> <td> <?php echo $rows['sound']; ?></td> <td> <?php echo $rows['gfx']; ?></td> <td> <?php echo $rows['recovery']; ?></td> <td> <?php echo $rows['date']; ?></td> <td> <?php echo $rows['valby']; ?></td> <td width="41" align="center"><a href="update.php?id=<?php echo $rows['id']; ?>">update</a></td> <td width="36" align="center"><a href="delete_ac.php?id=<?php echo $rows['id']; ?>">delete</a></td> </tr> <?php // table bg colour $choice = strtoupper($rows['gfx']); if($choice == "PASS"){ $bgc = "#7FFF00" ; }else{ $bgc = "#8B8989" ; } } ?> </table> <p> </p> </body> </html> Hi,
I'm having the following problem. I want to change the row color depending on the value of a record.
i made three different td class in the style.
Then i check the value of the record "TOEGEZEGD" and connect this to $NewClass,
The i try to change the color of the background.
$NewClass takes the value i want (check by display echo $NewClass)
But the background of the row doesn't change, i tried different methodes:
<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> But non of them work please help, it's driving my crazy <?php // checking for started session function is_session_started() { if ( php_sapi_name() !== 'cli' ) { if ( version_compare(phpversion(), '5.4.0', '>=') ) { return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; } else { return session_id() === '' ? FALSE : TRUE; } } return FALSE; } if ( is_session_started() === FALSE ) session_start(); if(isset($_SESSION ['ingelogd']) AND $_SESSION['ingelogd'] == 1) {} else { header("location:index.php"); exit; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>**********</title> <meta name="" content=""> </head> <body> <style> textarea, input, button, a, td, span{ font-family: "Trebuchet MS", Helvetica, sans-serif; } td{ color: blue; width: 100px; background-color: #ceffce; height: 50px; text-align: center; } td.JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } .JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } td.NEE{ color: green; width: 100px; background-color: #ff0000; height: 50px; text-align: left; } td.MISSCHIEN{ color: orange; width: 100px; background-color: #f07700; height: 50px; text-align: left; } td.op{ color: black; width: 450px; background-color: #ceDDce!important; height: 50px; text-align: left; } th{ color: black; width: 40px; background-color: #cecece; height: 50px; text-align: center; } th.op{ color: black; width: 450px; background-color: #cecece; height: 50px; text-align: center; } .a{ height: 25%; cursor: pointer; } button{ width: 100%; height: 100%; margin: -5 auto -5 auto; } textarea { height: 100%; width: 100%; } .verwijder{ width: 10px; height: auto; background-color: #ffa8a8; } .space{ width: 20px; height: auto; } .invoegen{ background-color: #6dbbdc; width: 1434px; padding: 5px; margin: 5px; } .content{ background-color: #FFDD67; width: 1500px; ; padding: 0 5 0 5; margin: 0 5 0 5; } .content table{ margin-bottom: 100px; } span{ text-decoration: underline; } select{ height: 90%; } </style> <div class="content"> <?php mysql_connect("localhost", "************", "*********") or die(mysql_error()); mysql_select_db("*********"); $sql = "SELECT ID, NAAM, CONTACT, TOEGEZEGD, bestuur1, bestuur2, bestuur3, bestuur4, bestuur5, VORM, PAKKET, KANGEFACTUREERD, GEFACTUREERD, AANTAL, POST, OPMERKING FROM `sponsoren` ORDER BY $field $sort"; $result = mysql_query($sql) or die(mysql_error()); echo'<table>'; while($row = mysql_fetch_array($result)) { $BESTUUR1 = $row['bestuur1']; $BESTUUR2 = $row['bestuur2']; $BESTUUR3 = $row['bestuur3']; $BESTUUR4 = $row['bestuur4']; $BESTUUR5 = $row['bestuur5']; if ($row['TOEGEZEGD'] == 'ja') { $NewClass = "JA" ; } elseif ($row['TOEGEZEGD'] == 'nee') { $NewClass = "NEE"; } elseif ($row['TOEGEZEGD'] == 'misschien') { $NewClass = "MISSCHIEN"; } echo $NewClass; echo'<tr> <td><a href="full_table_row_results.php?ID='.$row['ID'].'">'.$row['ID'].'</a></td> <td>'.$row['NAAM'].'</td> <td>'.$row['CONTACT'].'</td> <td >'; if($BESTUUR1 == 1){ echo "<div class='item'><label>Kk</label></div>"; }; if($BESTUUR2 == 1){ echo "<div class='item'><label>Rutger</label></div>"; }; if($BESTUUR3 == 1){ echo "<div class='item'><label>Toby</label></div>"; }; if($BESTUUR4 == 1){ echo "<div class='item'><label>Meijke</label></div>"; }; if($BESTUUR5 == 1){ echo "<div class='item'><label>Boele</label></div>"; }"</td>"; echo'<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> <td>'.$row['KANGEFACTUREERD'].'</td> <td>'.$row['GEFACTUREERD'].'</td> <td>'.$row['AANTAL'].'</td> <td>'.$row['POST'].'</td> <td class = "op">'.$row['OPMERKING'].'</td>'; echo'</tr>'; } echo'</table>'; ?> </div> </body> </html> I have a navigation bar that allows the user to change its color. When the color is changed it fades from one color to another. I am trying to make the background do the same. It currently changes color but doesn't have the same fade effect.
Navigation Bar:
var value = $(this).attr('data-color'); $('.navbar').removeClass().addClass('navbar '+ value); return false;Page Background: function colorPink() { document.body.style.backgroundColor = "#FF47D1"; }What can I do to make them both fade? Thanks, Good day: I'm trying to get the following output to alternate colors of background (white and gray or other colors). Any help will be appreciated. (This is the entire script so far.) <html> <body> <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT * FROM articles WHERE id=1"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Article</font></th> <th><font face="Arial, Helvetica, sans-serif">Year</font></th> <th><font face="Arial, Helvetica, sans-serif">Description</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"article"); $f2=mysql_result($result,$i,"year"); $f3=mysql_result($result,$i,"description"); $f4=mysql_result($result,$i,"location"); $f5=mysql_result($result,$i,"link") ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td ><font face="Arial, Helvetica, sans-serif"><?php echo "<a href=\"$f5\" target=\"_blank\">$f4</a>"; ?></font></td> </tr> <tr> </tr> <?php $i++; } ?> </body> </html> I am letting users select there color code option for text-shadow for there username I am storing them into a field called "color" HEX exaMPLE: FF6633,AA3633 First is the background color, 2nd is the foreground. (then i'll explode them) Is there a PHP function that let's me validate the input so it's HEX ONLY? I will be db escaping it and intval it too. I wrote a script in ActionScript that takes an image and does color correction, giving me the same results as photoshop's "Auto Color" feature. The actionscript uses an image matrix that looks like this: Code: [Select] var cmf:ColorMatrixFilter = new ColorMatrixFilter(new Array( R, 0, 0, 0, 0, 0, G, 0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0, 1, 0 )); This is different from the php GD's matrix imageconvolution(), which is only 3x3 where the actionscript one is 5x4. I think this is why I am getting different image results. Any suggestions to get the two to act the same? I am stumped... Hey Guys! First off, great looking resource, looks like tons of helpful people here. Secondly, I'll upload the file I need help with. Basically I'm looking to change the color of certain words that don't show up well now that I changed the background color.. but there are so many things in this script I can't figure out which one to change. I'm trying to change the words across the top that are in grey, to a lighter color. The site is laughing2myself.com if you need to have a look THANKS! Any help would be greatly appreciated! I have a system on my forum where the admin can change the colors of certain elements. Take the divs with and id of header for example. They can change the color of these and the value is added to the database. Then in my initialize file which is always called with every page, i set the color for the headers to the database value: $color['headers'] = $row['headers']; but then i have to go to every header div and add <div id="header" style="color:'.$color['headers'].'";> this means doing this for every header div and i dont just allow them to change the font color, but also background color and borders. Would there be a better way of doing this without adding these variables to the style attr of the element? when i view the code in firebug there are alot of style attr with all of these variables and it makes the code look a mess, and also makes it tedious work to add these variables to every element. Thanks Hi there!, I am trying to figure out how to use preg_replace or preg_match. I want to search a text block and add a color style to all the links. How is this possible? Code: [Select] Logical Example: Search - > "<a href="whatever.php?id=123&sid=2312">" and replace with <a href="whatever.php?id=123&sid=2312" style="color: rgb(255, 250, 255);"> Hi I'm trying to make use of an array with usernames in it and want to make use of it to display users with those usernames in a certain color in this case Im trying red.
I've made an array with username in it
$admin = array("SYSOP","~cobusbo~");and I've tried to print these messages with color with the If function without luck if ($name == $admin) { $name = print '<span style="color:red">' . $_SERVER["HTTP_X_MXIT_NICK"] . '</span>'; } else { $name = print $_SERVER["HTTP_X_MXIT_NICK"]; }Here is my full code <?php /*** begin the session ***/ session_start(); /*** create the form token ***/ $form_token = uniqid(); /*** add the form token to the session ***/ $_SESSION['form_token'] = $form_token; define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); // database connection info $conn = mysql_connect('**********','********','**********') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('u506124311_cobus',$conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; /* * StringyChat * * Please refer to readme.txt supplied with the StringyChat distribution for information on * installing and configuring. * */ define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); include("chat_code_header.php"); $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); $myrow = mysql_fetch_array($result); $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on $install_url = $myrow["install_url"]; // URL to install dir of StringyChat $name_size = $myrow["name_size"]; // Maximum size of the name $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit. $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split. $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display. $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes $email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) { $StringyChat_name = $_POST['StringyChat_name']; $StringyChat_message = $_POST['StringyChat_message']; } ?> <div id="StringyChat"> <? // Check if visitor's IP is banned. If so, do not display the form, // show a banned IP message instead. $ip = $_SERVER["REMOTE_ADDR"]; $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\""; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["ip"] == "") { // Checks if IP not found in banned list ?> <html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <br> <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php $name ?>1" size="20"> <br> <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="4"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </html> <? } else { echo "Posting disabled - Your IP has been banned."; } // Should we try to create a post? if (isset($StringyChat_name) && isset($StringyChat_message)) { // Remove whitespaces and slashes. $name = trim(stripslashes($StringyChat_name)); $message = trim(stripslashes($StringyChat_message)); // Check name and message have been entered. if (strlen($name) > 0 && strlen($message) > 0) { // Limit the size of the fields as per variable defnitions. if (strlen($name) > $name_size) { $name = substr($name, 0, $name_size); } if (strlen($message) > $message_size) { $message = substr($message, 0, $message_size); } // Remove new lines from name. $name = str_replace("\n", " ", $name); // Stripping out \r's so email formattnig appears correctly. $message = str_replace("\r", "", $message); // Create an email-friendly version of the message. $message_emailable = str_replace("<br>", "\n", $message); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable); } // Replace the new lines with encoded line breaks for HTML (thanks milahu). $message = str_replace("\n", "c#lb", $message); // Use HTML encoding on ame and message so database doesn't misinterpret data. $name = htmlentities($name); $message = htmlentities($message, ENT_COMPAT); // IP address of submitter and time of post. $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_NICK"]; $msg = $_POST['StringyChat_message']; $post_time = date("U"); $admin = array("SYSOP","~cobusbo~"); $mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"]; if ($name == $admin) { $name = print '<span style="color:red">' . $_SERVER["HTTP_X_MXIT_NICK"] . '</span>'; } else { $name = print $_SERVER["HTTP_X_MXIT_NICK"]; } if(!isset($mxitid, $name )) { $mxitid = "DEFAULT"; $name = "SYSOP"; } // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 3600 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time,mxit_id) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time,$mxitid)"; $result = mysql_query($sql); $theTo = $email_notification_to; $theSubject = "New StringyChat post at ".$domain_installed; $theMessage = "A new StringyChat post has been made.\n\n"; $theMessage .= $name . "\n"; $theMessage .= date("H:i - d/m/y", $post_time) . "\n"; $theMessage .= $message_emailable . "\n\n"; $theMessage .= "Visit ".$domain_installed." to view StringyChat and much more!"; $theHeaders = "From: StringyChat at ".$domain_installed." <".$email_notification_to.">\r\n"; mail($theTo,$theSubject,$theMessage,$theHeaders); } else { echo "Duplicate post detected<br>"; } } else { echo "<font color=\"red\">You must Type a message</font><br><br>"; } unset($_POST["StringyChat_name"]); unset($_POST["StringyChat_message"]); unset($StringyChat_ip); unset($StringyChat_name); unset($StringyChat_message); unset($StringyChat_time); } // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />'; } // Load up the last few posts. The number to load is defined by the "ShowPostNum" variable. $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db); include("sort_widths.php"); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; // Convert the encoded line break into an actual <br> tag (thanks milahu) $msg = str_replace("c#lb", "<br>", $msg); // Convert the encoded image tag into a html tag $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg); // split the lines $msg = htmlwrap($msg, $line_length); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $msg = ereg_replace($the_word, ":-x",$msg); } } ?> <? // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> <html> <i>Type your Message here...</i>:<br></html> Hi, I am builing a CMS , where user can choose the colors for menus, body and etc. At present am having a form where users wants to enter the color name. But what i am trying to make a color picker to choose the colors from the palette. How can i integrate the color palattes in my website, and please give me some inputs. Thank you I want to change the background to a light gray if the value of the $UOMPDROPSEQUENCE field is an odd number.
What would be the best way to do this please keep in mind I am very new to programming and PHP Thanks
Below is a snippet of my code.
$result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } echo "<table><tr>"; echo "<th>Drop</th>"; echo "<th>Name</th>"; echo "<th>Note</th>"; echo "<th>PO</th>"; echo "<th>Box_count</th>"; echo "<th>Cubes</th>"; echo "<th>ADDRESSLINE</th>"; echo "<th>ADDRESS2</th>"; echo "<th>CITY</th>"; echo "<th>STATE</th>"; echo "<th>ZIP</th>"; echo "<th>Order_ID</th>"; echo "<th> Phone </th>"; while (odbc_fetch_row($result)) { $UOMPDROPSEQUENCE=odbc_result($result,"UOMPDROPSEQUENCE"); $cmlName=odbc_result($result,"cmlName"); $UCMLSTOREHOURSTXT=odbc_result($result,"UCMLSTOREHOURSTXT"); $ompCustomerPO=odbc_result($result,"ompCustomerPO"); $UOMPTOTALBOXCOUNT=odbc_result($result,"UOMPTOTALBOXCOUNT"); $UOMPVOLUMETOTAL=odbc_result($result,"UOMPVOLUMETOTAL"); $CMLADDRESSLINE1=odbc_result($result,"CMLADDRESSLINE1"); $CMLADDRESSLINE2=odbc_result($result,"CMLADDRESSLINE2"); $CMLCITY=odbc_result($result,"CMLCITY"); $CMLSTATE=odbc_result($result,"CMLSTATE"); $CMLPOSTCODE=odbc_result($result,"CMLPOSTCODE"); $ompSalesOrderID=odbc_result($result,"ompSalesOrderID"); $cmlPhoneNumber=odbc_result($result,"cmlPhoneNumber"); echo "<tr><td>$UOMPDROPSEQUENCE </td>"; echo "<td align='center'>$cmlPhoneNumber</td>"; echo "<td align='center'>$UCMLSTOREHOURSTXT</td>"; echo "<td align='center'>$ompCustomerPO</td>"; echo "<td align='center'>$UOMPTOTALBOXCOUNT</td>"; echo "<td align='center'>$UOMPVOLUMETOTAL</td>"; echo "<td align='center'>$CMLADDRESSLINE1</td>"; echo "<td align='center'>$CMLADDRESSLINE2</td>"; echo "<td align='center'>$CMLCITY</td>"; echo "<td align='center'>$CMLSTATE</td>"; echo "<td align='center'>$CMLPOSTCODE</td>"; echo "<td align='center'>$ompSalesOrderID</td>"; echo "<td align='center'> $cmlPhoneNumber</td></tr>"; } odbc_close($connect); |