Jump to content

cypher86

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by cypher86

  1. right! follow the ginerjm way
  2. 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
  3. 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
  4. 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
  5. $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++; }
  6. i'm so sorry. i don't know what i was testing. now with the code given in the first post works correctly
  7. 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.
  8. 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?
  9. 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?
  10. 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>
  11. 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.
  12. nothing append. the last log seems to refer to 9:15 am while i load the page now...
  13. ok thx. i add the @ORM\Entity and repalce the datetime doctrine type with date. now a strange thing append.... when i refresh the page it gives me a blank page.
  14. ok i'm totally confused... what am i doing wrong???? Nominativo entity: <?php namespace Fatturazione\FatturazioneBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Length; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="nominativo") * @ORM\HasLifecycleCallbacks */ class Nominativo { /** * @ORM\id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="string") */ protected $nominativo; /** * @ORM\Column(type="string") */ protected $indirizzo; /** * @ORM\Column(type="string") */ protected $pi; /** * @ORM\Column(type="string") */ protected $cf; /** * @ORM\Column(type="string") */ protected $tel; /** * @ORM\Column(type="string") */ protected $fax; /** * @ORM\Column(type="string") */ protected $email; public function getNominativo() { return $this->nominativo; } public function setNominativo($nominativo) { $this->nominativo=$nominativo; } public function getIndirizzo() { return $this->indirizzo; } public function setIndirizzo($indirizzo) { $this->indirizzo=$indirizzo; } public function getPi() { return $this->pi; } public function setPi($pi) { $this->pi=$pi; } public function getCf() { return $this->cf; } public function setCf($cf) { $this->cf=$cf; } public function getTel() { return $this->tel; } public function setTel($tel) { $this->tel=$tel; } public function getFax() { return $this->fax; } public function setFax($fax) { $this->fax=$fax; } public function getEmail() { return $this->email; } public function setEmail($email) { $this->email=$email; } public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('nominativo', new NotBlank()); $metadata->addPropertyConstraint('nominativo', new Length(array('max'=>50, 'maxMessage'=>'Testo massimo di 50 caratteri'))); $metadata->addPropertyConstraint('indirizzo', new NotBlank()); $metadata->addPropertyConstraint('indirizzo', new Length(array('max'=>50, 'maxMessage'=>'Testo massimo di 50 caratteri'))); $metadata->addPropertyConstraint('pi', new NotBlank()); $metadata->addPropertyConstraint('pi', new Length(array('max'=>20, 'maxMessage'=>'Testo massimo di 20 caratteri'))); $metadata->addPropertyConstraint('cf', new NotBlank()); $metadata->addPropertyConstraint('cf', new Length(array('max'=>20, 'maxMessage'=>'Testo massimo di 20 caratteri'))); $metadata->addPropertyConstraint('tel', new NotBlank()); $metadata->addPropertyConstraint('tel', new Length(array('max'=>20, 'maxMessage'=>'Testo massimo di 20 caratteri'))); $metadata->addPropertyConstraint('fax', new NotBlank()); $metadata->addPropertyConstraint('fax', new Length(array('max'=>20, 'maxMessage'=>'Testo massimo di 20 caratteri'))); $metadata->addPropertyConstraint('email', new Email()); } public function getNominativi($limit = null) { $qb = $this->createQueryBuilder('b') ->select('b.id, b.nominativo') ->addOrderBy('b.nominativo', 'ASC'); if (false === is_null($limit)) $qb->setMaxResults($limit); return $qb->getQuery() ->getResult(); } public function __toString() { return getNominativi(); } } ?> causale entity: <?php namespace Fatturazione\FatturazioneBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Date; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="causale") * @ORM\HasLifecycleCallbacks */ class Causale { /** * @ORM\id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="datetime") */ protected $data; /** * @ORM\Column(type="string") */ protected $descrizione; /** * @ORM\Column(type="number") */ protected $onorario; /** * @ORM\Column(type="number") */ protected $spese; /** * @ORM\Column(type="number") */ protected $rimborsi; /** * @ORM\ManyToOne(targetEntity="Nominativo", inversedBy="causale") * @ORM\JoinColumn(name="nominativo", referencedColumnName="id") * @ORM\Column(type="integer") */ protected $nominativo; protected $tipoCausale; public function getId() { return $this->id; } public function setId($id) { $this->id=$id; } public function getData() { return $this->data; } public function setData($data) { $this->data=$data; } public function getDescrizione() { return $this->descrizione; } public function setDescrizione($descrizione) { $this->descrizione=$descrizione; } public function getOnorario() { return $this->onorario; } public function setOnorario($onorario) { $this->onorario=$onorario; } public function getSpese() { return $this->spese; } public function setSpese($spese) { $this->spese=$spese; } public function getRimborsi() { return $this->rimborsi; } public function setRimborsi($rimborsi) { $this->rimborsi=$rimborsi; } public function getNominativo() { return $this->nominativo; } public function setNominativo($nominativo) { $this->nominativo=$nominativo; } public function getTipoCausale() { return $this->tipoCausale; } public function setTipoCausale($tipoCausale) { $this->tipoCausale=$tipoCausale; } public function __toString() { return $this->getNominativo; } public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('data', new NotBlank()); $metadata->addPropertyConstraint('data', new Date(array('message'=>'Data non valida'))); $metadata->addPropertyConstraint('descrizione', new Length(array('max'=>200, 'maxMessage'=>'Testo massimo di 200 caratteri'))); } } ?> form: <?php namespace Fatturazione\FatturazioneBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Doctrine\ORM\EntityRepository; class CausaleType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('data','date',array('widget' => 'single_text', 'format' => 'yyyy-MM-dd')); $builder->add('descrizione'); $builder->add('onorario','number'); $builder->add('spese','number'); $builder->add('rimborsi','number'); $builder->add('nominativo','entity', array('class' => 'FatturazioneFatturazioneBundle:Causale', 'expanded' => 'false', 'multiple' => 'false')); $builder->add('tipoCausale','choice',array('choices' => array('0' => 'Fattura', '1' => 'Causale'), 'required' => true)); } public function getName() { return 'causale'; } } ?>
  15. my need is to create a combobox that takes its values from a table (or generally a query)
  16. i don't understand. should i put the method getNominativi inside the entity Nominativo and create a method that returns the name of the class? it doesnt make sense to me ...... can you please have the patience to do me an example? thx
  17. i edited as follows: $builder->add('nominativo','entity', array('class' => 'Fatturazione\FatturazioneBundle\Entity\Repository\NominativoRepository', 'property' => 'getNominativi')); the class NominativoRepository: <?php namespace Fatturazione\FatturazioneBundle\Entity\Repository; use Doctrine\ORM\EntityRepository; class NominativoRepository extends EntityRepository { public function getNominativi($limit = null) { $qb = $this->createQueryBuilder('b') ->select('b.id, b.nominativo') ->addOrderBy('b.nominativo', 'ASC'); if (false === is_null($limit)) $qb->setMaxResults($limit); return $qb->getQuery() ->getResult(); } } ?> but i get the following error Class "Fatturazione\FatturazioneBundle\Entity\Repository\NominativoRepository" seems not to be a managed Doctrine entity. Did you forget to map it?
  18. hello, as you said i added an entity object as follow: $builder->add('data','date',array('widget' => 'single_text', 'format' => 'yyyy-MM-dd')); $builder->add('descrizione'); $builder->add('onorario','number'); $builder->add('spese','number'); $builder->add('rimborsi','number'); $builder->add('nominativo','entity', array('class' => 'FatturazioneFatturazioneBundle:Nominativo:getNominativi')); $builder->add('tipoCausale','choice',array('choices' => array('0' => 'Fattura', '1' => 'Causale'), 'required' => true)); but i get this error: A "__toString()" method was not found on the objects of type "Fatturazione\FatturazioneBundle\Entity\Nominativo" passed to the choice field. To read a custom getter instead, set the option "property" to the desired property path.
  19. sorry, here the link http://postimg.org/image/mnn7mgczb/
  20. hello, i already have an application written in php. i created the application few years ago and i have not uses an object style. i'd like to port it on symfony. one of a thousand problem i'm having is this: i have a form which insert the data and if selected from a table it can update it. here the link at the image (it seems i'm not allowed to insert images) if i click on the radio button the page populate the form and permit to update it. how can i reach the same or similar result?
  21. hi all, i'm absolutely new to symfony. i'm trying to create a form for class "Causale" which has in it a combobox refering a "Nominativo". i created a "Nominativo" repository and i'm trying to get all the value on the referenced table in order to populate the combobox on the "Causale" form. CODE: SELECT ALL class CausaleType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $nominativi=new NominativoRepository(); $builder->add('data','date',array('widget' => 'single_text', 'format' => 'yyyy-MM-dd')); $builder->add('descrizione'); $builder->add('onorario','number'); $builder->add('spese','number'); $builder->add('rimborsi','number'); $builder->add('nominativo','choice', $nominativi=getNominativi(null)); $builder->add('tipoCausale','choice',array('choices' => array('0' => 'Fattura', '1' => 'Causale'), 'required' => true)); } public function getName() { return 'causale'; } } CODE: SELECT ALL class NominativoRepository extends EntityRepository { public function getNominativi($limit = null) { $qb = $this->createQueryBuilder('b') ->select('b') ->addOrderBy('b.nominativo', 'ASC'); if (false === is_null($limit)) $qb->setMaxResults($limit); return $qb->getQuery() ->getResult(); } } unfortunately i get this error CODE: SELECT ALL Warning: Missing argument 1 for Doctrine\ORM\EntityRepository::__construct(), called where am i wrong? thanks in advance
  22. hi all, i have an application that i wrote on my own without the use of any framework (sequential style). i'd like to port it on zend framework, so i started with the skeleton application tutorial. now i'm trying to shape the skeleton application in order to reach my goal. is that the right way? instead of using the model mapping a class for each table i'd like to let the logic on the db creating procedures that return the result that has to be shown in the view. how can i do that?
  23. i agree with you. but as you said if i want absolute path and use / or DEOCUMENT_ROOT it redirects me to (for exemple) http://localhost/var/www/myapp which is obiously wrong.
  24. ok but how i do instrunct the include to manage the pat as a uri instead of the document root?
  25. hi guys, the problem is that if i follow your instructions there is something wrong. follow an example: suppose i have the following file system: web server root | |----lib |----another_dir the script i'm working on is under "another_dir" in which i have to include a script under "lib". so i type include('/lib/script.php'); php returns me an error of script not found. if i use instead include('../lib/script.php') the script is found. why's that?
×
×
  • 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.