Jump to content

imgrooot

Members
  • Posts

    383
  • Joined

  • Last visited

  • Days Won

    1

Community Answers

  1. imgrooot's post in Is there a better way to do php ajax live search from the database? was marked as the answer   
    Alright so I figured it out. Based on your code, here's my new code. And in the backend-search.php, I had to change $_POST to $_GET. Now it works great. Thanks so much.
    <script type='text/javascript'> $().ready(function() { $('#display-cities').hide(); $("#city-box").keyup(function() { var term = $(this).val(); $.get("snippets/backend-search.php", {"term":term}, function(resp) { $("#display-cities").html("").show(); $.each(resp, function(k,v) { var citydata = '<div class="output-results"><p class="output-p1">' + v.cityname + '</p><p class="output-p2">' + v.provincename + ', '+ v.countryname + '</p></div>'; var citydata2 = '' + v.cityname + ', ' + v.provincename + ', ' + v.countryname + ''; $("#display-cities").append(citydata); $( ".output-results" ).click(function() { $("#city-box-id").val(val.cityid); $("#city-box").val(citydata2); $("#display-cities").html(citydata).hide(); }); }) }, "JSON" ) }) }) </script>  
  2. imgrooot's post in GROUP BY not working properly when used with multiple joined tables was marked as the answer   
    Actually I found the issue. My query works fine. The issue was that only 1 user in my database matched all three parameters.  Which is  why it was only showing a single result. So it's all good now.
    Having said that if you would like to modify my query to show your example, that'd be great.
  3. imgrooot's post in How do I highlight mysql fetch dates in a datepicker? was marked as the answer   
    I found the mistake. All I had to do was to add a "," after the beforeShowday to separate it from the onSelect function. You could've just told me this.
    Also I don't even have to create a variable outside the ajax as you previously told me. It works fine without it. 
    Here's the updated code.
    <script> $(document).ready(function() { function formattedDate(d = new Date) { let month = String(d.getMonth() + 1); let day = String(d.getDate()); const year = String(d.getFullYear()); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return `${year}-${month}-${day}`; } $.ajax({ type: "POST", url: 'snippets/adapter-fetch.php', data: {}, dataType: 'json', success: function(highlighted) { $('#datetimepicker1').datepicker({ dateFormat: "yy-mm-dd", multidate: true, beforeShowDay: function(date) { newDate = formattedDate(date); for(let x=0; x < highlighted.length; x++) { console.log(highlighted[x], newDate); if (highlighted[x] === newDate) { return [true, 'Highlighted', '']; // that 3rd index is the tooltip text } } return [true, '']; // default if not a highlight }, onSelect: function () { var getDate = $("#datetimepicker1").val(); $.ajax({ type: "POST", url: "snippets/adapter-set.php", data: { date: getDate }, success: function(data) { // alert(data); }, error: function() { alert("Error."); } }); } }); } }); }); </script>  
  4. imgrooot's post in How do I convert php array to individual variables? was marked as the answer   
    Oh wow, it works. That was simple.  Thank you.
  5. imgrooot's post in Php and MySQL database problem with retrieving data with double quotes was marked as the answer   
    Never mind.  I found the solution. When I output the variable, I have to use htmlentities like this htmlentities($variable_output).
  6. imgrooot's post in Quick help with update query was marked as the answer   
    Ah yes.  I did add the return and it now works.
    function getIt($var) { $pos = strpos($var, ' - '); return substr($var, $pos+3); }
  7. imgrooot's post in How do you order by Asc and DESC with decimal numbers in MySQl database? was marked as the answer   
    Yes you're right.  Thanks a bunch.
  8. imgrooot's post in Is there a way to verticle scroll the mobile dropdown menu if it's larger than the screen? was marked as the answer   
    One small edit. Add the height: 100%. It'll fix any y scrolling issue.  Here's the updated code.
    .nav-mobile { display: none; height: 100%; *zoom: 1; position: fixed; width: 100%; overflow-y: scroll; -ms-overflow-y: scroll; -webkit-overflow-scrolling: touch; // mobile safari }
  9. imgrooot's post in Is it better to use to id or actual name when relating to another table in MySQL database? was marked as the answer   
    Got ya. Thanks.
  10. imgrooot's post in How do you show php foreach loop results as ajax mousehover? was marked as the answer   
    Yep the above works if I have the ".show-details" div as a child of parent div ".product" like this.
    <div class="product"> <div class="product-title"> <?php echo $get_record_title; ?> </div> <div class="product-price"> <?php echo $get_record_price; ?> </div> <div class="show-details"> <?php echo $get_record_details; ?> </div> </div>
  11. imgrooot's post in Uploading an image gives me move_upload_file error was marked as the answer   
    Your comment made me think of something.  So I added this code and now it works.
    if(!is_dir($target_dir)){ mkdir($target_dir, 0775, true); }
  12. imgrooot's post in How would you add form input values array into multiple rows in MySQL table? was marked as the answer   
    Alright so I have it working now.  For future reference, here's the entire code based on what "benanamen" wrote.
    // get record id from url parameter $record_id = $_GET['record_id']; if(isset($_POST['submit']) { $insertStmt = $db->prepare("INSERT INTO datatable (record_id, title, description) VALUES (?,?,?)"); for ($i = 0; $i < count($_POST['title']); $i++) { $insertStmt->execute(array( $record_id, $_POST['title'][$i], $_POST['description'][$i] )); if($insertStmt == true) { echo 'success'; } else { echo 'false'; } } } <form action="" method="post"> <input type="text" name="title[]" value="" /> <input type="text" name="title[]" value="" /> <input type="text" name="description[]" value="" /> <input type="text" name="description[]" value="" /> <input type="submit" name="submit" value="Post" /> </form>
  13. imgrooot's post in I have a javascript countdown timer but would like to know how to add a cookie to it was marked as the answer   
    Can you please double check your above code?  It's giving me an error "ReferenceError: Timer is not defined".
    Which is this line.
    new Timer($('.<?php echo $counterName; ?>'), <?php echo $timeLeft; ?>);
×
×
  • 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.