Jump to content

azraelGG

Members
  • Posts

    32
  • Joined

  • Last visited

azraelGG's Achievements

Member

Member (2/5)

0

Reputation

  1. i need echo out <input id="mjernaJedinica" value="kg" /> <input id="ekoloskiProizvod" value="E" /> this is what i get <input id="mjernaJedinica" value="kg E" />
  2. i need display something on my website when id is set - i get good result but i dont know how to devide .val(data) in 2 variables if(isset($_POST['proID'])){ $proID = $_POST['proID']; $query = new WP_Query(array('post_type' => 'plodovi', 'p'=>$proID)); while ( $query->have_posts() ) : $query->the_post(); ?> <?php echo $mjernaJedinica = types_render_field("mjerna_jedinica", array("show_name"=>"")); ?> <?php echo $ekoloskiProizvod = types_render_field("ekoloski_proizvod", array("show_name"=>"")); ?> <?php endwhile; } and i get my result kg E and now i want that my function is displaying E in one id element and kg in other element function(data){ $("#mjernaJedinica").show(); $("#mjernaJedinica").html(data); $("#inputMjernaJedinica").val(data); // in this id element display kg $("#ekoloskiProizvod").val(data); // in this id element display E } when i leave like this i get it all in one row
  3. i tried with sprinf wrong way to do it this works great, thanks
  4. hi im doin some custom coding and i need use ROUND with ALWAYS 2 decimals so if i enter 2 i need get back 2,00 with , not .
  5. i need calculate average of some data ill use simple example table so if you can help me. i will use only 2 users and 2 products for example it must be ordered by datetime(time in this table) and then get last 2 prices per user_ID calculate average table name: prices user_ID post_ID price time 1 1 10 13:00 - pick this row 1 1 11 12:00 1 1 12 14:00 - pick this row 3 1 10 13:00 - pick this row 3 1 11 12:00 3 1 12 14:00 - pick this row 1 2 15 13:00 - pick this row 1 2 16 12:00 1 2 17 14:00 - pick this row 3 2 18 13:00 - pick this row 3 2 19 12:00 3 2 12 14:00 - pick this row /* if there are more users get their last 2 entries */ or just how to query these "- pick this row" rest is not that hard final result post_ID total_avg_price 1 11 2 15.5
  6. is it good practice to use create table if not exist or not? or i should just manually create tables ?
  7. can anyone help me convert post to ajax i want use beforesend option but its only avaliable in .ajax method this is post i want edit function ajaxDelete(id, tablica, tablica_col, trID){ var current = $(trID).closest('tr');//.attr('id'); if(confirm("Potvrdite brisanje")){ $.post("ajax/ajaxDelete.php", {id: id, tablica: tablica, tablica_col: tablica_col }, function(data){ }); beforeSend: current.animate({'backgroundColor':'#fb6c6c'},300); } }; and calling <td><a class="deleteReccord" style="cursor:pointer;" onclick="ajaxDelete('.$stroj['stroj_ID'].', \'stroj\', \'stroj_ID\',this);">Obriši</a></td>
  8. this code works, but only inside same file not in header.php
  9. im building function for delete rows from sql but im stuck on early stage of it and unable to solve it error msg in firebug console parametars that i get in console are correct, but i cant get that alert("works") code where i call function <td><a style="cursor:pointer;" onclick="ajaxDelete('.$stroj['stroj_ID'].', \'stroj\', \'stroj_ID\');" >Deletei</a></td> - jquery is included - it is not part of document ready functions (same results if its inside of it) //delete universal function ajaxDelete(id, tablica, tablica_col){ $.post("ajax/ajaxDelete.php", {id: id, tablica: tablica, tablica_col: tablica_col}, function(data){ alert("works"); }); };//endof delete universal
  10. i need check in condition did someone click button or didnt this button is used to display some jQuery and now i want different things to be loaded depending on is it clicked or not - page cant be refreshed that will lead in problem that i need click 2 times on that button <input id="popup" name="popup" type="submit" value="ADD" />
  11. i think that fetch_row() is for PDO only but my connecting is not over PDO in this case so i used standard $row = mysql_fetch_assoc($result) thanks for tip
  12. im trying to get 1 data column and store it in session variable so i can use it later i tried to do that on line 47 but without success when i try print_r($result) i get "resource id #8" here is the class file <?php class korisnik{ private $_ime; private $_prezime; private $_oib; private $_adresa; private $_email; private $_lozinka; private $_database; public function _construct(){ } //metoda koja provjerava da li je korisnik logiran public function isLogiran(){ //ukoliko je korisnik logiran if(isset($_SESSION['logiran'])&& isset($_SESSION['email'])){ return true; } //ukoliko korisnik nije logiran idi na index.php i vrati na index.php else { if( basename($_SERVER['PHP_SELF']) != "index.php" && basename($_SERVER['PHP_SELF']) != "registracija.php"){ header('Location: index.php'); } } } //metoda za logiranje public function getKosrinikLogin($email, $lozinka){ //provjera da li je upisano nešto u polja $lozinka = sha1($lozinka); if(!empty($email) && (!empty($lozinka))){ //pravljenje novog korisnika i provjera sql upita $korisnik = new Database(); $sql = "SELECT * FROM korisnik WHERE email = '$email' AND lozinka = '$lozinka'"; $result = $korisnik->query($sql); //provjeriti da li je samo jedan rezultat sql upita - provjerava ispravnos podataka $korisnikCount = mysql_num_rows($result); if($korisnikCount == 1){ //podesit session $_SESSION['logiran'] = "da"; $_SESSION['email'] = $_POST['email']; print_r($result); //ROW 45 HERE --------------------------------------------------- want get field ime from database table echo $result[0]['ime']; } // ukoliko unos nije ispravan else { echo "Unesite ispravne podatke"; } } // ako je polje prazno else { echo "Unesite e-mail adresu i šifru"; } }//end of getKorisnikLogin //metoda za registraciju public function registerKorisnik($ime, $prezime, $oib, $adresa, $email, $lozinka){ $lozinka = sha1($lozinka); //provjera polja if(!empty($ime) && (!empty($prezime)) && (!empty($oib)) && (!empty($adresa)) && (!empty($email)) && (!empty($lozinka))){ //ako su unešena sva polja provjeri podatke $sql = "SELECT * FROM korisnik WHERE email = '$email'"; $korisnik = new Database(); $emailCheck = $korisnik->query($sql); if(mysql_num_rows($emailCheck) == 0){ //ako email adresa nije zauzeta registriraj korisnika $registracija = "INSERT INTO korisnik (ime, prezime, oib, adresa, email, lozinka) VALUES ('{$ime}', '{$prezime}', '{$oib}', '{$adresa}', '{$email}', '{$lozinka}')"; //ZAŠTO OVAJ RED UPISUJE U BAZU PODATAKA ako ima if if($korisnik->zapis($registracija)){ echo "Uspješno ste se registrirali."; } else { echo "Došlo je do pogreške prilikom registracije. <br>"; echo mysql_error(); } } else if (mysql_num_rows($emailCheck) != 0){ echo "Ova e-mail adresa je već zauzeta."; } else { echo "Došlo je do pogreške, molimo pokušajte ponovo."; } } else { echo "Unesite sve podatke."; } }//end of registerKorisnik } ?> rest of the code works fine
  13. basename($_SERVER['PHP_SELF']) thanks for pointing me on right direction
  14. i just need to check am i on specific page index.php
  15. is there any why to check on which site am i? i need check am i on index.php or not any idea how to check 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.