Jump to content

cypher86

Members
  • Content Count

    88
  • Joined

  • Last visited

Community Reputation

0 Neutral

About cypher86

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. i think you got the parenthesis wrong while ($i < $size) { if ($arr[$i] == $num) { return TRUE; } else { i++; } return FALSE; } like this the while does 1 loop only. either find the number on the first hit or return false. should be more like $found=false while ($i < $size) { if ($arr[$i] == $num) { //return TRUE; $found=true; } else { i++; } //return FALSE; } return $found; this solution is not optimized because evaluate all the array even when not needed but does the trick
  2. php has already a built-in function that does the trick. it's called in_array() http://php.net/manual/en/function.in-array.php
  3. i didn't fully understand your question, still there is for sure an error in your script, an echo is missing <option value=<?""$lang""?>>Language selection</option> should be <option value="<?php echo $lang; ?>">Language selection</option> in order to work
  4. $row is already in that format. anyway try this $i=0; while($row = mysql_fetch_assoc($result)) { $co-ordinate[$i]= ( "postcode" => $row['postcode'], "latitude" => $row['latitude'], "longitude" => $row['longitude'] ); $i++; }
  5. i'm so sorry. i don't know what i was testing. now with the code given in the first post works correctly
  6. yes no error are diplayed, the json is returned and seems identical to the one returned from the first script then it returns nothing. since the json is returned i assume that the parameters are correctly set.
  7. sorry for the double posting. the script does not return any error. echoing the results i don't see any difference. do you need me to post the two results?
  8. hello, i developed a php script which get called via autocomplete jQuery. surfing the internet i found the following script that does the work $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends $qstring = "query text"; $result = mysql_query($qstring);//query the database for entries containing the term while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values { $row['field1']=htmlentities(stripslashes($row['field1'])); $row['field2']=htmlentities(stripslashes($row['field2'])); $row['field3']=htmlentities(stripslashes($row['field3'])); $row['id']=(int)$row['id']; $row_set[] = $row;//build an array } echo json_encode($row_set);//format the array into json data but i wanted (for security reason) to use bind parameter so i convert it to $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends $qstring = "query string"; $search="%$term%"; $sql=$db->prepare($qstring); $sql->bind_param('s',$search); $sql->execute(); $sql->bind_result($id,$field1,$field2,$field3); //build an array while($sql->fetch()) { $row['id']=(int)$id; $row['field1']=htmlentities(stripslashes($field1)); $row['field2']=htmlentities(stripslashes($field2)); $row['field3']=htmlentities(stripslashes($field3)); $row_set[]=$row; } echo json_encode($row_set);//format the array into json data*/ i echoed the output and seems identical to me, still with the first script the autocomplete works while the second don't. any clue?
  9. hello, i'm facing this problem. i have a main page with the definition of tab. each tab is a different page called by ajax when selected. in some tabs i'd like to add datepickers but i'm having trouble. when i load the tab the datepicker does not work. do you have any suggestion or a better way to do this? thanks here's the code i'm using main.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script> <script src="../lib/datepicker-it.js"></script> <script type="text/javascript" src="../lib/rollover.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="../css/screen.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../css/jqueryobject.css" /> <script> $(document).ready(function() { $( "#tabs" ).tabs({ }); }); </script> </head> <body> <?php include ("../top.php"); ?> <br /> <fieldset><legend>Ricerche</legend> <div id="tabs"> <ul> <li><a href="tab1.php">Tab1</a></li> <li><a href="tab2.php">Tab2</a></li> <li><a href="tab3.php">Tab3</a></li> </ul> </div> </fieldset> </body> </html> tab1.php <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script> <script> $(document).ready(function() { $.datepicker.setDefaults( $.datepicker.regional[ "it" ] ); $( ".datepicker" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd/mm/yy", beforeShowDay: highlightOddsEven, showOtherMonths: true, selectOtherMonths: true }); function highlightOddsEven(date) { //return [true, date.getDate() % 2 == 1 ? 'odd' : '']; return [true, date.getDate() % 2 == 1 ? 'oddEven' : 'oddEven']; } </script> <div id="termConsegna" name="termConsegna"> <fieldset><legend>Termini Consegna</legend> <form class="cmxform" name="form_termine" id="form_termine" method="post" action="tab1.php"> <input type="hidden" id="submit" name="submit" value="1"> <table id="tab_termine" class="css-table"> <?php $i=1; while($sql->fetch()){ echo "<tr> <td>da <input type=\"text\" name=\"data_da$i\" id=\"data_da$i\" class=\"datepicker\" pattern=\"\d{1,2}/\d{1,2}/\d{4}\" $dateValidation value=\"".dbDateToNormal($da)."\"></td> <td> a <input type=\"text\" name=\"data_a$i\" id=\"data_a$i\" class=\"datepicker\" pattern=\"\d{1,2}/\d{1,2}/\d{4}\" $dateValidation value=\"".dbDateToNormal($a)."\"></td> <td><input type=\"text\" name=\"data_termine$i\" id=\"data_termine$i\" class=\"datepicker\" pattern=\"\d{1,2}/\d{1,2}/\d{4}\" $dateValidation value=\"".dbDateToNormal($termine)."\"></td> </tr>"; $i++; } ?> <input type="hidden" name="num_termini" id="num_termini" value="<?php echo $i; ?>"> <tr><td colspan="3"><input type="submit" value="Salva"></td></tr> </table> </form> </fieldset> </div> tab2.php <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script> <script> $(document).ready(function() { $.datepicker.setDefaults( $.datepicker.regional[ "it" ] ); $( ".datepicker" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd/mm/yy", beforeShowDay: highlightOddsEven, showOtherMonths: true, selectOtherMonths: true }); function highlightOddsEven(date) { //return [true, date.getDate() % 2 == 1 ? 'odd' : '']; return [true, date.getDate() % 2 == 1 ? 'oddEven' : 'oddEven']; } </script> <div id="ricAvanz" name="ricAvanz"> <fieldset><legend>Ricerca Avanzata</legend> <form class="cmxform" id="form_ricerca" name="form_ricerca" action="ricerca.php" method="post"> <input type="hidden" id="ricerca" name="ricerca" value="1"> <p><label>Data1: </label>da:<input type="text" name="da_comparizione" id="da_comparizione" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?> value="<?php if(isset($_POST['ricerca'])) echo $_POST['da_comparizione']; ?>" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?>><label> </label>a:<input type="text" name="a_comparizione" id="a_comparizione" value="<?php if(isset($_POST['ricerca'])) echo $_POST['a_comparizione']; ?>" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php if(isset($_POST['ricerca'])) echo $dateValidation; ?>></p> <p><label>Data2: </label><input type="text" name="asta_si" id="asta_si" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?> value="<?php if(isset($_POST['ricerca'])) echo $_POST['asta_si']; ?>" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?>></p> <p><label>Data3: </label><input type="text" name="asta_ci" id="asta_ci" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?> value="<?php if(isset($_POST['ricerca'])) echo $_POST['asta_ci']; ?>" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?>></p> <p><label>Data4: </label><input type="text" name="sloggio_pa" id="sloggio_pa" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?> value="<?php if(isset($_POST['ricerca'])) echo $_POST['sloggio_pa']; ?>" class="datepicker" pattern="\d{1,2}/\d{1,2}/\d{4}" <?php echo $dateValidation; ?>></p> <p><input type="submit" value="Cerca"></p> </form> <fieldset> <?php echo $fieldset; while (isset($_POST['ricerca']) and $ricerca->fetch()) echo "<p><a href=\"../esecuzioni/panel_generale.php\">.......</a></p>"; ?> </fieldset> </div>
  10. i'm using jquery autocomplete with a remote php script. this code works fine: db_connect(); $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends $qstring = "SELECT id,nominativo,indirizzo,telefono,fax,e_mail FROM legale WHERE nominativo LIKE '%".$term."%'"; $result = mysql_query($qstring);//query the database for entries containing the term while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values { $row['nominativo']=htmlentities(stripslashes($row['nominativo'])); $row['indirizzo']=htmlentities(stripslashes($row['indirizzo'])); $row['telefono']=htmlentities(stripslashes($row['telefono'])); $row['fax']=htmlentities(stripslashes($row['fax'])); $row['e_mail']=htmlentities(stripslashes($row['e_mail'])); $row['id']=(int)$row['id']; $row_set[] = $row;//build an array } echo json_encode($row_set);//format the array into json data this one doesn't: $db=db_connect_param(); $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends if($_GET['what']=="legale") $qstring = "SELECT id,nominativo,indirizzo,telefono,fax,e_mail FROM legale WHERE nominativo LIKE ?"; $search="%$term%"; $sql=$db->prepare($qstring); $sql->bind_param('s',$search); $sql->execute(); $sql->bind_result($id,$nominativo,$indirizzo,$telefono,$fax,$e_mail); //build an array while($sql->fetch()) { $row['nominativo']=htmlentities(stripslashes($nominativo)); $row['indirizzo']=htmlentities(stripslashes($indirizzo)); $row['telefono']=htmlentities(stripslashes($telefono)); $row['fax']=htmlentities(stripslashes($fax)); $row['e_mail']=htmlentities(stripslashes($e_mail)); $row['id']=(int)$id; $row_set[]=$row; } echo json_encode($row_set);//format the array into json data*/ what's the difference? the json returned seems the same.
×
×
  • 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.