www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] PHP code not working SQL Results not showing all results

  1. #1
    Join Date
    Mar 2008
    Posts
    88

    resolved [RESOLVED] PHP code not working SQL Results not showing all results

    Hey Guys,


    The code below makes my datepicker grey out days which have been entered into my database but its gone a little weird! It only greys out certain dates which means the same date can be entered numerous times! Any idea why this code is not displaying all my results in my datepicker?

    Thanks

    PHP Code:
    <?php
    $out 
    = array(); 
    foreach(
    $_POST['place'] as $place){ 
        
    $out[] = ("'".mysql_real_escape_string($place)."'"); 

    $imploded implode(', '$out); 
    echo 
    $imploded;

    $date "SELECT date FROM activities WHERE place IN ($imploded)"

    $grey mysql_query($date)or die(mysql_error());
    ?>
    Code:
    var disabledDays = [
    
    <?php while ($row = mysql_fetch_array($grey, MYSQL_ASSOC)) {
       echo '' .$row['date']. ','; 
        
    }
    ?>
    ];
    
    /* create datepicker */
    jQuery(document).ready(function() {
    	
    	function displayVals() {     
    		var numdays = $("#num_days").val();
    		var date = new Date();
    		jQuery('#datepicker').multiDatesPicker({
    
    			dateFormat: "dd/mm/yy",
    			pickableRange:numdays,
    			adjustRangeToDisabled: true,
    			addDisabledDates: disabledDays
    			
    		});
    		
    	}   
    	$("#num_days").change(displayVals);    
    	displayVals();
    });

  2. #2
    Join Date
    Aug 2012
    Posts
    155
    What do you get when you echo $imploded, is it what you expect?
    Have you echo'd your query to ensure it is also as expected and then run in phpmyadmin to check that you are getting the expected results from the database? Does, your while loop work as expected?
    Test all of the elements separately to ensure your php is working and if so then I can only presume it is a problem with your jquery.

  3. #3
    Join Date
    Mar 2008
    Posts
    88
    All the tests worked fine but the one below looked weird:-

    They only value it greyed out it the first string.

    I put this in
    PHP Code:
    while($row mysql_fetch_assoc($grey)) {
        
    var_dump($row);

    result:-


    'array(1) { ["date"]=> string(12) "'01/11/2012'" } array(1) { ["date"]=> string(25) "'24/12/2012','25/12/2012'" }

  4. #4
    Join Date
    Mar 2008
    Posts
    88
    Found the problem!!

    There was a space being added to the database. The culprit ->

    PHP Code:

    $imploded 
    implode(', '$out); 
    Thanks for replying

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles