Jump to content

anderson_catchme

Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by anderson_catchme

  1. So I'm trying to unset array elements that don't contain "thumbnail" in the filename. Seems simple, but it's not working. function generateImage3 ($category, $imageornot, $Imagepointer) { if($imageornot == 1){ $var = get_cwd_uploads().'\\'.$Imagepointer; // get_cwd_uploads() is a custom function $scanned_directory = array_diff(scandir($var), array('..', '.')); foreach($scanned_directory as $elements){ $pos = strpos($elements, 'thumbnail'); if($pos === FALSE){ unset($scanned_directory[key($elements)]); } } // irrelevant code Any help appreciated.
  2. I'm a major JS noob and this is driving me nuts. I'm trying to use this in a form: http://reactiveraven.github.io/jqBootstrapValidation/ And using the examples, can't get anything to work. Only my browser's non-js HTML 5 form validation. Anybody have a simple that incorporates both HTML and JS? The examples only show the html.
  3. This is my code for displaying images from a folder: function generate_img ($imagepointer, $imageornot){ if($imageornot == 1){ $var = getcwd(); $dirlocation = $var."\\imageuploads\\".$imagepointer; $files = array_diff(scandir($dirlocation), array('..', '.')); foreach ($files as $image){ $data[] = array('label' => '<img src="/imageuploads/'.$imagepointer.'/'.$image.'" alt="thumbnail"> <br/>'); }; return $data; } else { return FALSE; } } I'm using it with print_r: <p><?php print_r(generate_img($imagepointer, $imageornot)); ?></p> Working ok, but obviously not good for a live site. Is implode() a good idea in this situation? And how would I use it? Appreciated.
  4. function create_image($ext, $filepath, $newfilepath, $jpegquality){ switch ($ext){ case "jpg" OR "jpeg": $im = @imagecreatefromjpeg($filepath); if($im){ imagejpeg($im, $newfilepath, $jpegquality); } break; case "gif": $im = @imagecreatefromgif($filepath); if($im){ imagegif($im, $newfilepath); } break; case "png": $im = @imagecreatefrompng($filepath); if($im){ imagepng($im, $newfilepath, 7); } break; } if(!$im){ return FALSE; } } $ext is my file extention. The rest is pretty self explanitory. It's working for JPEG, but somehow not PNG or GIF. Not sure why, help appreciated. Thanks.
  5. Fair enough. But how would I use $row = $stmt->fetchAll(); given my script? What would the while statement look like and could I use array notation for my column names? Thanks for everyone's input.
  6. <td> <button onclick="alertdialog()"><span class="glyphicon glyphicon-trash"> </span></button></td> <script> function alertdialog(){ window.confirm("Are you sure you want to delete this post?"); } </script> This is my code. I need to have a callback to a PHP script when a user decides to delete a post. I think html POST is the most unobtrustive way to do this. What's the easiest / most robust way to send data to a script when the user clicks OK? Appreciated. Mark
  7. class getjson { function query_db ($mysqli, $search_string){ $query = "SELECT name, location, address FROM csv_table WHERE address LIKE CONCAT('%',?,'%') OR name LIKE CONCAT('%',?,'%') OR location LIKE CONCAT('%',?,'%') LIMIT 0,5"; $stmt = $mysqli->prepare($query); $stmt->bind_param("sss", $search_string, $search_string, $search_string); $stmt->execute(); // $stmt->bind_result($name, $location, $address); // not necessary for code to work $result = $stmt->get_result(); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ foreach ($row as $value) { $data[] = array( 'label' => $value .', '. $value.' '. $value , 'value' => $value ); } } return $data; } } $results = new getjson; $results = $results->query_db($mysqli, $search_string); print_r($results); echo count($results); I have the following code. It works, but I cannot get array notation working correctly. For instance, I would like to access $row['address'] to input into my array in the foreach statement. But I can't seem to get it to work after a couple hours. So any ideas appreciated. Thanks, Mark
  8. Hello forum, So I've been developing an app mostly in PHP, but am rather afraid of JS. Hope to fix that. I have an AJAX dropdown using JQuery to search locations. It works great. However, I want to make it similar to what is seen on this site: http://placefinder.com/ As you can see, the dropdown, when clicked populates a box. Then the user submits the form and the data is used in the application. I have no clue how to make the form populate with data from the DB (I'm using mySQL) when clicked. So far, I've only been able to make it clickable as a URL (not what I want, obvioiusly!) Is there a way to do this on a really small, simple script for starters? I'm certain their is, but don't even know where to begin. Any help appreciated
×
×
  • 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.