PHP - Change Image
Using php I have a dynamically filled select box with the names of images. How can I get an image box on my page and change upon selection?
Similar TutorialsHi all, I am dealing with an html page in which a dynamically created PNG image is shown with: <img src="createchart.php"> The problem arises when users try to download the image since the default name that appears is just "createchart.php". Is there any way to make the browser suggest something like "chart.png"? Than you guys for your help, Mam This creates an image 1500x1500 pixels. But it creates it in black... how can i make it white. And i have to use imagecreatetruecolor() not imagecreate(). <?php $im = imagecreatetruecolor(1500,1500); // Output the image to the browser header('Content-type: image/jpg'); imagejpeg($im); imagedestroy($im); ?> Thanks! 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! Hi,
I want to show one image for the new visitors of my website and another for the returning visitors. What I want to do is that after the visitor reload the page he will see another image instead of the first one.
HI I'm thinking to do something like this , I've seen this in a website ,I'm a php designer but i don't know who something like this can be done . it's a website that sells sofas . we've the ability to change the color and fabric and see the result right away . for example ,this is the default sofa : then I can select a part of it and I can choose the fabric and color , then it make the result : thats it , How can I do that ? What should I do ? I'm really looking to hear from you King Regards Currently, I insert a small thumbnail image at the begging of each row in a set of records from a mysql query. But that image is the same image for each record in that array. Is there a way to conditionally change which image is used, based on a value either in that same table, or a related table. See attached screenshot... and here's my current code.... Code: [Select] <?php $query = "select address from nvc"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $details=''; $details.='<li class="menu"><a href=detail.php?address='.(urlencode($row['address'])).'><img src="thumbs/house.png" /><span class="name">'.$row['city'].'</a>'; $details.='</li>'; echo($details); } ?> Thank you for any input. i am new to web designing,
i don't know much about javascript.
<select id="plan" align="center" valign="center"> Hey guys! I have the following php code that grabs variables (and the browsed image) from Flash. //FLASH VARIABLES $Name = $_POST['Name']; $itemNumber = $_POST['itemNumber']; $filename = $_FILES['Filedata']['name']; $filetmpname = $_FILES['Filedata']['tmp_name']; $fileType = $_FILES["Filedata"]["type"]; $fileSizeMB = ($_FILES["Filedata"]["size"] / 1024 / 1000); list($filename, $extension) = explode('.', basename($_FILES['Filedata']['name'])); $filename = $Name; $target = $filename . $itemNumber . "." . $extension; // Place file on server, into the images folder move_uploaded_file($_FILES['Filedata']['tmp_name'], "images/".$target); This works perfect, but what I want to change is the width and height of the uploaded image. Any ideas/suggestions on how this could be done? Thanks in advance!! Cheers! I have a PHP script that uploads images to a folder on my server (attachments folder). Currently the folder sits within my webroot and is publicly accessible (I have to use chmod 777 due to permissions issue). So, I created the "attachments" folder outside of my webroot (so that it is not publicly accessible), but I do not know how to set the path in the PHP code to upload it to that "attachments" folder outside of the webroot. As you see in the snippet of PHP code below, the code currently uploads the the "attachments" folder within the www (webroot) directory. How do I make it upload to the "attachments" folder OUTSIDE of the www (webroot) directory? foreach($files[$form] as $file){ $str = $file[1]; if (eval("if($str){return true;}")) { $_values[$file[0]] = $_FILES[$file[0]]["name"]; $dirs = explode("/","attachments//"); $cur_dir ="."; foreach($dirs as $dir){ $cur_dir = $cur_dir."/".$dir; if (!@opendir($cur_dir)) { mkdir($cur_dir, 0777);}} $_values[$file[0]."_real-name"] = "attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure"; copy($_FILES[$file[0]]["tmp_name"],$_values[$file[0]."_real-name"]); @unlink($_FILES[$file[0]]["tmp_name"]); }else{ $flag=true; if ($_isdisplay) { //$ExtFltr = $file[2]; //$FileSize = $file[4]; if (!eval("if($file[2]){return true;}")){echo $file[3];} if (!eval("if($file[4]){return true;}")){echo $file[5];} $_ErrorList[] = $file[0]; } } } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347058.0 Need to change the value in an XML string tried the following but no luck, any suggestions?
$_xml_string = '<Order> <EmbeddedDoc DocumentName="TestDoc" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> <EmbeddedDoc DocumentName="TestDoc1" DocumentFormat="PDF">jdsahfdhflhfsdlfhdslhsdflsdfhflkdslkfsdhkfhskldhkl</EmbeddedDoc> </Order>'; foreach($_xml_string->Order->EmbeddedDoc as $document) { $document ='##FILE_CONTENT##'; } <?php require_once('config/config.php'); include ("files/viator/api.php"); $page = new PhpCode(); $current_page = $page->curPageURL(); $_SESSION['last_page'] = $current_page ; function seoUrl($string) { //Lower case everything $string = strtolower($string); //Make alphanumeric (removes all other characters) $string = preg_replace("/[^a-z0-9_\s-]/", "", $string); //Clean up multiple dashes or whitespaces $string = preg_replace("/[\s-]+/", " ", $string); //Convert whitespaces and underscore to dash $string = preg_replace("/[\s_]/", "-", $string); return $string; } if(isset($_GET['submit']) && !empty($_GET['submit'])) { $lookupId = $_GET['lookupId']; $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } else if(isset($_GET['search_submit']) && !empty($_GET['search_submit'])){ $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; $lookupId = $_GET['lookupId']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } else { $lookupId = $_GET['lookupId']; $dest_code = $_GET['dest_code']; $currency_code = $_GET['currency_code']; $sortOrder = $_GET['sortOrder']; $catId = $_GET['catId']; $subcategoryId = $_GET['subcategoryId']; $country_name = $_GET['country_name']; $state_name = $_GET['state_name']; $country_dest_id= $_GET['country_dest_id']; $check_in = $_GET['check_in']; $check_out = $_GET['check_out']; if($dest_code =='' && $country_dest_id != '') { $dest_code = $country_dest_id; } } $getdataarr = getAdventureSearch($dest_code,$currency_code,$sortOrder,$check_in,$check_out); $adventure_data_arr = $getdataarr['data']; $image = '' ; $part = new Body(); $title = "Things to do in "; if($state_name !="") { $title .= $state_name.' ' ;} if ($country_name=="United States of America") { $title .= 'USA ' ; $breadcrumb = 'USA';} elseif ($country_name=="United Arab Emirates") { $title .= 'UAE ' ; $breadcrumb = 'UAE'; } elseif ($country_name!="") { $title .= $country_name; } $title .= " | Compare & Choose"; $meta = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today." /><link rel="canonical" href="//www.compareandchoose.com.au/adventure_list"/> <!-- MICROFORMATS FOR GPLUS --> <link href="https://plus.google.com/+CompareandchooseAuTravel/posts" rel="publisher" /> <meta itemprop="name" content="' .$title. '"> <meta itemprop="description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today."> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="website" /> <meta property="og:title" content="' .$title. '" /> <meta property="og:description" content="' .$state_name. ' Attractions & Things to do in ' .$country_name. '. Find your adventure in ' .$country_name. ' Today." /> <meta property="og:url" content="http://www.compareandchoose.com.au/" /> <meta property="og:site_name" content="Compare and Choose" /> <meta property="article:publisher" content="https://www.facebook.com/compareandchoose" /> <meta property="fb:app_id" content="1386609318277530" /> <meta property="og:image" content="http://www.compareandchoose.com.au/images/Compare-and-Choose-logo.png" /> <meta property="og:image:width" content="313" /> <meta property="og:image:height" content="75" />'; $head = $part->getHead($title,$meta); $header = $part->getHeader('Adventure'); $footer = $part->getFooter(); echo $head; echo $header; ?> <script> function sort() { $('.overlay_wrap').fadeIn(); $('.loader_hotel_page').fadeIn(); } </script> <div class="overlay_wrap" style="display: none;"></div> <div class="loader_hotel_page" style="display: none;"><img src="<?php echo SITE_URL; ?>images/search-loader.gif" alt="searching-records"/></div> <!-----Adventure Listing-----> <div class="container"> <div class="listing"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <div class="refine-search travel"> <?php require_once('files/keyword_search.php'); ?> <div class="block"> <div class="block-content"> <div class="block-title">Top Selling Tours & Activities</div> <div class="block-inner"> <div class="top-rated-pic"> <!--<img src="images/small-pic1.png" alt="" />--> </div> <div class="top-topics-sec"> <?php $getcatdataarr = getCategoryDestination($dest_code); $category_arr = $getcatdataarr['data']; $i=1; if($category_arr !="") { foreach ($category_arr as $categoryList) { if($catId == $categoryList['id']) { $image = $categoryList['thumbnailURL']; $groupName = $categoryList['groupName']; ?> <p onclick="sort()"> <strong><?php echo $i;?>.</strong><a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($categoryList['groupName']);?></a> <?php $subcategories_arr = $categoryList['subcategories']; foreach($subcategories_arr as $subcatList) { echo '<br>'; ?> <a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&subcategoryId=<?php echo $subcatList['subcategoryId'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($subcatList['subcategoryName']); ?></a> <?php } ?> </p> <?php } else{ ?> <p onclick="sort()"><strong><?php echo $i;?>.</strong><a href="adventure_list.php?currency_code=<?php echo $currency_code; ?>&dest_code=<?php echo $dest_code;?>&sortOrder=<?php echo $sortOrder;?>&catId=<?php echo $categoryList['id'];?>&country_name=<?php echo $country_name;?>&state_name=<?php echo $state_name;?>&country_dest_id=<?php echo $country_dest_id; ?>&lookupId=<?php echo $lookupId;?>&check_in=<?php echo $check_in;?>&check_out=<?php echo $check_out;?>"><?php echo stripslashes($categoryList['groupName']);?></a></p> <?php }$i++;} } ?> </div></div></div></div></div></div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-main"> <div class="row"> <?php if($image !='') { //$image = 'images/travel-pic.png'; ?> <div class="col-xs-12 col-md-4 col-lg-4"> <!--<img src="<?php echo $image;?>" alt="" />--> </div> <?php } ?> <div class="col-xs-12"> <h1>Things to do in <?php echo stripslashes($country_name);?></h1> <?php if($state_name == '') { $search_name = $country_name; } else{ $search_name = $state_name; } ?> <p>Compare and choose things to do in <?php echo stripslashes($search_name);?></p> <a href="#"><?php echo strtoupper(stripslashes($search_name));?> >></a> <?php if($groupName != '') { echo '<p>'.$groupName.'</p>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET"> <div class="filtering"> <select onchange="this.form.submit();" name="sortOrder"> <option value="TOP_SELLERS" <?php if($sortOrder == 'TOP_SELLERS'){echo 'selected';}?>>Most Popular</option> <option value="REVIEW_AVG_RATING_D" <?php if($sortOrder == 'REVIEW_AVG_RATING_D'){echo 'selected';}?>>Top Rated</option> <option value="PRICE_FROM_A" <?php if($sortOrder == 'PRICE_FROM_A'){echo 'selected';}?>>Price(Low - High)</option> <option value="PRICE_FROM_D" <?php if($sortOrder == 'PRICE_FROM_D'){echo 'selected';}?>>Price(High - Low)</option> </select> <input type="hidden" name="currency_code" value="<?php echo $currency_code;?>" id="currency_code"> <input type="hidden" name="lookupId" value="<?php echo $lookupId;?>" id="lookupId"> <input type="hidden" name="dest_code" value="<?php echo $dest_code;?>" id="dest_code"> <input type="hidden" name="catId" value="<?php echo $catId;?>" id="catId"> <input type="hidden" name="subcategoryId" value="<?php echo $subcategoryId;?>" id="subcategoryId"> <input type="hidden" name="country_name" value="<?php echo $country_name; ?>" id="country_name" > <input type="hidden" name="state_name" value="<?php echo $state_name;?>" id="state_name"> <input type="hidden" name="country_dest_id" value="<?php echo $country_dest_id;?>" id="country_dest_id"> </div> </form> </div><div class="c1"></div></div></div> <?php if($adventure_data_arr != ""){ foreach($adventure_data_arr as $adventureList) { $url = seoUrl($adventureList['title']); if($catId == '') { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3 spacal-img"> <?php if($adventureList['specialOfferAvailable'] == 1) {?> <div class="spacal-tag"> <img src="images/specila-tag.png" alt="" /> </div> <?php } ?> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h2 style="text-transform: uppercase; font: 400 15px 'Open Sans', sans-serif; text-decoration: none;"><a style="color: rgb(103, 191, 54);" href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>&lookupId=<?php echo $lookupId;?>&dest_code=<?php echo $dest_code; ?>"><?php echo stripslashes($adventureList['title']);?></a></h2> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <div class="ratings"> <?php $rate = $adventureList['rating']; $f= floor($rate); $c = ceil($rate); $cnt = 0; if($rate!="" && $rate!=0) { for($in = 1; $in<=$rate ;$in++) { $cnt++; ?> <img src="images/rating_full.png"> <?php } if($f != $c) { $cnt++; ?> <img src="images/rating_half.png"> <?php } } if($cnt<5) { while($cnt<5) { $cnt++; ?> <img src="images/rating_blank.png"> <?php } } ?> <!--<span class="stars"><?php echo $adventureList['rating']; ?></span>--> </div> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>&lookupId=<?php echo $lookupId;?>&dest_code=<?php echo $dest_code; ?>"> <span style="float: right; margin-right: 1%; padding: 6px 20px; color: white; background-color: rgb(108, 191, 61); text-align: center; font-size:16px; font-weight:400; ">See Details →</span></a> <span class="new_price">Duration :<?php echo stripslashes($adventureList['duration']);?></span><br /> <span class="new_price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></span> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <div class="original"> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> </div> <div class="save-price"> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> </div> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } else { if($subcategoryId == '') { $catgory_arr = $adventureList['catIds']; if(in_array($catId, $catgory_arr)) { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h1><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>"><?php echo stripslashes($adventureList['title']);?></a></h1> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <span class="stars"><?php echo $adventureList['rating']; ?></span> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"> <div class="price">Duration :<?php echo stripslashes($adventureList['duration']);?></div> <div class="price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></div> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <h3>Special Offer </h3> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } } else{ $sub_catgory_arr = $adventureList['subCatIds']; if(in_array($subcategoryId, $sub_catgory_arr)) { ?> <div class="travel-list-sec"> <div class="row"> <div class="col-xs-12 col-md-3 col-lg-3"> <img src="<?php echo $adventureList['thumbnailHiResURL'];?>" alt="" width="166" height="160" /> </div> <div class="col-xs-12 col-md-9 col-lg-9"> <div class="travel-det"> <h1><a href="adventure_details.php?name=<?php echo $url;?>&code=<?php echo $adventureList['code'];?>¤cyCode=<?php echo $adventureList['currencyCode'];?>"><?php echo stripslashes($adventureList['title']);?></a></h1> <p><?php echo stripslashes($adventureList['shortDescription']);?></p> <div class="rating-box"> <span class="stars"><?php echo $adventureList['rating']; ?></span> <div class="rating-txt"> based on <?php echo $adventureList['reviewCount']; ?> reviews </div> <div class="c1"></div> </div> <div class="price-box"> <div class="price">Duration :<?php echo stripslashes($adventureList['duration']);?></div> <div class="price">From <?php echo stripslashes($adventureList['currencyCode']);?> <?php echo stripslashes($adventureList['priceFormatted']);?></div> <?php if($adventureList['specialOfferAvailable'] == 1) { ?> <h3>Special Offer </h3> <p>Original Price : <?php echo stripslashes($adventureList['rrpformatted']);?></p> <p>Saving Amount : <?php echo stripslashes($adventureList['savingAmountFormated']);?></p> <?php } ?> </div></div></div><div class="c1"></div></div></div> <?php } } } } } ?> </div><div class="breadcrumb-new"> <ul> <li><div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a href="<?php echo SITE_URL;?>" itemprop="url"><span itemprop="title">Home</span></a><span>></span> </div></li> <li><strong>Adventures & Activities in <?php echo $state_name. ',' .$country_name; ?></strong></li> </ul> </div><div class="c1"></div></div></div></div> <?php echo $footer ;?> </body> </html>Hi All I am trying to change my website from http to https and I have ran into a problem with one of the scripts producing a none secure http problem Basically when I check this it shows a none secure error ERROR insecure url = http://cache.graphic...m/etcetcetc.jpg which needs to be https://cache.graphi...m/etcetcetc.jpg I thinks it is something to do with the array $adventureList array on line 285(not exactly sure, as I didn't write the code and I am not an expert) So my question is how do I change this to https url please find attached my page code thanks in advance all Alan Sir, i know that we can change the user agent via cURL. i want to know is possible to change ip ? Hi all I'm new to PHP so i might ask easy stuff Here is my Scenario I click a button .. this work fine But in the php code that runs after the button is clicked i need to change the Website uri (link) to something like this after button postback index?name=value How am i gonna do this . I tried header function but it did not work well Any suggestion please The script for creating a new file name for the image:
$validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of imageThe script creates a new file like: f6c9b8d9db05366c3504210cded9ddb2.jpgand moves the file to the "uploads" folder. And then the script also creates a thumbnail with the same file name and moves the file to the "thumbs" folder. The issue I am having is that the same ID code could happen again for a different image in the database, thus I would be calling a different original sized image than the thumbnail image. My question is: How to avoid this issue of the same ID code has happened again for a different file. What is the proper way to reference the anchor tag of the thumbnail image to its actual original sized image? With the script I have the thumbnail image would be coming from the "thumbs" folder and the anchor tag would get referenced to the "uploads" folder to get the original sized image. Edited by glassfish, 12 October 2014 - 05:51 AM. After image is drop into container , I want to move copy of the original image to be move when original image dragend within container. I tried but it display copy image each time when original image dragend. can anyone help me?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Prototype</title> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.2.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script> <style> body{padding:20px;} #container{ border:solid 1px #ccc; margin-top: 10px; width:350px; height:350px; } #toolbar{ width:350px; height:35px; border:solid 1px blue; } </style> <script> $(function(){ var $house=$("#house"); $house.hide(); var $stageContainer=$("#container"); var stageOffset=$stageContainer.offset(); var offsetX=stageOffset.left; var offsetY=stageOffset.top; var stage = new Kinetic.Stage({ container: 'container', width: 350, height: 350 }); var layer = new Kinetic.Layer(); stage.add(layer); var image1=new Image(); image1.onload=function(){ $house.show(); } image1.src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"; $house.draggable({ helper:'clone', }); $house.data("url","house.png"); // key-value pair $house.data("width","32"); // key-value pair $house.data("height","33"); // key-value pair $house.data("image",image1); // key-value pair $stageContainer.droppable({ drop:dragDrop, }); function dragDrop(e,ui){ var x=parseInt(ui.offset.left-offsetX); var y=parseInt(ui.offset.top-offsetY); var element=ui.draggable; var data=element.data("url"); var theImage=element.data("image"); var image = new Kinetic.Image({ name:data, x:x, y:y, image:theImage, draggable: true, dragBoundFunc: function(pos) { return { x: pos.x, y: this.getAbsolutePosition().y } } }); image.on("dragend", function(e) { var points = image.getPosition(); var image1 = new Kinetic.Image({ name: data, id: "imageantry", x: points.x+65, y: points.y, image: theImage, draggable: false }); layer.add(image1); layer.draw(); }); image.on('dblclick', function() { image.remove(); layer.draw(); }); layer.add(image); layer.draw(); } }); // end $(function(){}); </script> </head> <body> <div id="toolbar"> <img id="house" width=32 height=32 src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"><br> </div> <div id="container"></div> </body> </html> Edited by Biruntha, 08 January 2015 - 10:14 AM. Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). How can i edit just one image at on time with a multiple image upload form? I have the images being stored in a folder and the path being stored in MySQL. I also have the files being uploaded with a unique id. My issue is that I want to be able to pass the values of what is already in $name2 $name3 $name4 if I only want to edit $name1. I don't want to have to manually update the 4 images. Here is the PHP: Code: [Select] <?php require_once('storescripts/connect.php'); mysql_select_db($database_phpimage,$phpimage); $uploadDir = 'upload/'; if(isset($_POST['upload'])) { foreach ($_FILES as $file) { $fileName = $file['name']; $tmpName = $file['tmp_name']; $fileSize = $file['size']; $fileType = $file['type']; if ($fileName != ""){ $filePath = $uploadDir; $fileName = str_replace(" ", "_", $fileName); //Split the name into the base name and extension $pathInfo = pathinfo($fileName); $fileName_base = $pathInfo['fileName']; $fileName_ext = $pathInfo['extension']; //now we re-assemble the file name, sticking the output of uniqid into it //and keep doing this in a loop until we generate a name that //does not already exist (most likely we will get that first try) do { $fileName = $fileName_base . uniqid() . '.' . $fileName_ext; } while (file_exists($filePath.$fileName)); $file_names [] = $fileName; $result = move_uploaded_file($tmpName, $filePath.$fileName); } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $fileinsert[] = $filePath; } } $mid = mysql_real_escape_string(trim($_POST['mid'])); $cat = mysql_real_escape_string(trim($_POST['cat'])); $item = mysql_real_escape_string(trim($_POST['item'])); $price = mysql_real_escape_string(trim($_POST['price'])); $about = mysql_real_escape_string(trim($_POST['about'])); $fields = array(); $values = array(); $updateVals = array(); for($i = 0; $i < 4; $i++) { $values[$i] = isset($file_names[$i]) ? mysql_real_escape_string($file_names[$i]) : ''; if($values[$i] != '') { $updateVals[] = 'name' . ($i + 1) . " = '{$values[$i]}'"; } } $updateNames = ''; if(count($updateVals)) { $updateNames = ", " . implode(', ', $updateVals); } $update = "INSERT INTO image (mid, cid, item, price, about, name1, name2, name3, name4) VALUES ('$mid', '$cat', '$item', '$price', '$about', '$values[0]', '$values[1]', '$values[2]', '$values[3]') ON DUPLICATE KEY UPDATE cid = '$cat', item = '$item', price = '$price', about = '$about' $updateNames"; $result = mysql_query($update) or die (mysql_error()); 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> |