Jump to content

azraelGG

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by azraelGG

  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?
  16. i work on some code that on every click will add input field to my html and that part works fine, but i want that field to have an ID next to it so i can use it for my database and php after heres the code <script type="text/javascript"> var counter = 1; $(document).ready(function(){ $("#addCestica").click(function(){ counter++; //$("#sveCestice").append("<br /><input id=\"cestica\" "+this.counter" />"); $("#sveCestice").append("<br /> <input />").attr("id",this.counter); }); $("#removeCestica").click(function(){ counter--; $("br:last").remove(); $("#sveCestice input:last").remove(); }); }); </script> paragraph where i display input fields is empty
  17. hm... i can set paragraph to display none and then it hides, but wont show entries when i press add button if i set select on display none nothing happens script put that entry inside of select as option but what i need to do is modify that and use only input part with list of entries (with remove), and get entries (that are not removed) as array so i can serialize it and store it to database PS if you know any other js plugin/script that can do job feel free to suggest this is first thing i found that can input (unlimited) entries
  18. so i use jquery script asmSelect for something now i stuck at 2 things 1. how do i hide that select field 2. how do i get all variables in array - i need to serialize array after heres the code (part of the code i use more input fileds and some selects for ful form have another button for sending all to sql) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.ui.js"></script> <script type="text/javascript" src="../jquery.asmselect.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#cestice").asmSelect({ animate: true, highlight: true, sortable: true }); $("#add_cestice_btn").click(function() { var cestice = $("#add_cestice").val(); var $option = $("<option></option>").text(cestice).attr("selected", true); $("#cestice").append($option).change(); $("#add_cestice").val(''); return false; }); }); </script> <link rel="stylesheet" type="text/css" href="../jquery.asmselect.css" /> </head> <body> <?php if(!empty($_POST['submit'])) { if(!empty($_POST['cestice'])) { foreach($_POST['cestice'] as $cestica) { // exclude any items with chars we don't want, just in case someone is playing if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $cestica)) continue; // print the city echo "\n\t<li>" . htmlspecialchars($cestica) . "</li>"; } echo "\n</ul>"; } else { echo "\n<p>No items selected</p>"; } } ?> <form action="" method="post"> <p style="hidden"> <select id="cestice" multiple="multiple" name="cestice[]" style="display: hidden"> </select> </p> <p><em>You may click and drag cities to order of preference.</em></p> </form> <p> <label for="add_cestice">Dodaj česticu</label> <input type="text" id="add_cestice" value="" /> <button type="button" id="add_cestice_btn" href="#">Dodaj</button> </p> </body> </html>
  19. yea... my root foler is not what i tought it is... missing name of project in it
  20. i looked some tutorial how to upload files, and got some script i should use for that, but i cant set good values for my destination folder i guess can you tell me where do i get things wrong if(!empty($_FILES)){ $tempFile = str_replace(" ", "", $_FILES['picUpload']['tmp_name']); $targetPath = $_SERVER['DOCUMENT_ROOT'].'/images/mehanizacija/'; $broj = rand(100,999); $targetFile = str_replace(" ", "", $targetPath.$broj.'-'.$_FILES['picUpload']['name']); $linkPicture = str_replace(" ", "", "http://localhost/images/mehanizacija/".$broj.'-'.$_FILES['picUpload']['name']); move_uploaded_file($tempFile, $targetFile); } line76 move_uploaded_file($tempFile, $targetFile); i use submit button from form that have multiple forms so i need that if(!empty($_FILES)) and in $linkPicture can i also use $_SERVER['DOCUMENT_ROOT'] so if i send this to some server he will look in my root folder and not directly on link that i will need to change
  21. azraelGG

    Sql Help

    yea it works now, it loads it normal + 2 cols that i need. thanks
  22. azraelGG

    Sql Help

    can you help me with this code i want select all fields from 3 tables but i need specific names for 2 coloums SELECT mp.naziv AS mpnaziv,vm.naziv AS vmnaziv, * (i want add this * like select all but when i add that * then query doesnt work) FROM mehanizacija m, mehanizacija_proizvodjac mp, vrsta_mehanizacija vm WHERE m.meh_proiz_ID_FK=mp.meh_proiz_ID AND m.vrsta_mehanizacija_ID_FK=vm.vrsta_mehanizacija_ID any suggestions, solutions?
  23. oh... it works when i erase but if field has remembered values then it colors them in yellow when its erased then its back to normal with background
  24. strange... i dont have any extensions installed (btw im on linux ubuntu mybe that can be problem) its fresh installation few days ago
  25. found the problem - autocomplete="off" but i would like to keep that autocompete on but chrome just set it on yellow by default any easy solutions?
×
×
  • 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.