Jump to content

thugsr

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by thugsr

  1. My trigger in this case should be selected value. For first two selects i get the value, only for third i cant..
  2. But i need selected value, not change. This should be part with pre-selected value.
  3. Hi, I have problem with this line var value = $("#opstina option:selected").val(); , but only in chrome i get that value is undefined. In FireFox, and IE, works fine, only in chrome i get this warning. Does someone know why? My whole jquery code is if ($("#drzava option:selected").length) { $("select#opstina").attr("disabled","disabled"); $("select#opstina").html("<option>wait...</option>"); var id = $("select#drzava option:selected").attr('value'); $.post("select_opstina.php", {id:id}, function(data){ $("select#opstina").removeAttr("disabled"); alert( "html koji bi trebao biti upisan u select:\n\n" + data ); $("select#opstina").html(data); }); if ($("#opstina option:selected").length) { alert('Došao sam pred petlju'); var value = $("#opstina option:selected").val();//this is line that is problem alert(value); var sel = $("#opstina").val(); // this do the same if (sel!=0) { alert('Ušao sam u petlju, i selektovano polje za opštinu je' + sel ); $("select#mesto").attr("disabled","disabled"); $("select#mesto").html("<option>wait...</option>"); var id= $("select#opstina option:selected").attr('value'); alert(id); $.post("select_mesto.php", {id:id}, function(data){ alert("html koji bi trebao biti upisan u select:\n\n" + data ); $("select#mesto").removeAttr("disabled"); $("select#mesto").html(data); }); } } } }
  4. In my first post is code of function, on that i changed line $niz[] = display_children($row['parent_id'], $level+1); like this,and in other variation i try with for loop where counter $i was key in array, that isn't worked as well...i need this to be stored into array display_children($row['parent_id'], $level+1);
  5. That don't work for my case... any other suggestion?
  6. I thought it would be better to learn this way. Create custom framework, see how it is done, along the way learn framework functionality and then learn one of the freamworks.
  7. Hi, I have problem with recursive function. I want to store value form that function into array because i need to reverse result of function. Here is function function display_children($category_id, $level) { global $database; $result = mysql_query("SELECT * FROM parents WHERE id_roditelja='$category_id'") or die(mysql_error()); $broj = $database->num_rows($result); $niz = array(); while ($row = mysql_fetch_array($result)) { echo str_repeat(' ',$level) . $row['naziv'] . "-> "; $niz = display_children($row['parent_id'], $level+1); } } I just want to save "display_children($row['parent_id'], $level+1)" this into an array reverse it and then return it. Can someone help me with this?
  8. I am junior php developer, so for my practice i want to create one framework. It would be basic and later i can expend it. So, my question is what that framework need to have? Some guidelines would be nice
  9. Hi everyone, I have problem with my accordion menu. Instead of sliding down, content from menu overlap each other...Cut me a little slack because i am new to javascript. This is code for menu. <?php include("script/dblib.php"); connectToDB(); header("Content-Type: text/html; charset=UTF-8"); ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="script/script.js"></script> <STYLE> #accordion { list-style: none; padding: 0 0 0 0; width: 230px; } #accordion li{ height:45px; line-height:45px; display: block; background-image:url('images/for_css/menu_bg.jpg'); background-repeat:repeat-x repeat-y; font-weight: bold; padding-left: 5px; cursor: pointer; list-style: circle; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } #accordion ul { list-style: none; padding: 0 0 0 0; display: none; } #accordion li:hover{ background-image:url('images/for_css/bgMenu.png'); } #accordion ul li{ height:30px; text-align: center; font-size: 12px; font-weight: normal; cursor: auto; background-image:url('images/for_css/bc_bg.gif'); line-height:30px; padding: 0 0 0 7px; } #accordion ul li:hover { background-image:url('images/for_css/bgMenu.png'); } #accordion a { text-decoration: none; } </STYLE> </HEAD> <BODY> <?php // Select all entries from the menu table $result=mysql_query("SELECT * FROM parents ORDER BY id_roditelja"); // Create a multidimensional array to conatin a list of items and parents $menu = array( 'items' => array(), 'parents' => array() ); // Builds the array lists with data from the menu table while ($items = mysql_fetch_assoc($result)) { // Creates entry into items array with current menu item id ie. $menu['items'][1] $menu['items'][$items['id_roditelja']] = $items; // Creates entry into parents array. Parents array contains a list of all items with children $menu['parents'][$items['parent_id']][] = $items['id_roditelja']; } // Menu builder function, parentId 0 is the root function buildMenu($parent, $menu) { $html = ""; if (isset($menu['parents'][$parent])) { $html .= " <ul id='accordion'>\n"; foreach ($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { $html .= "<li>\n <a >".$menu['items'][$itemId]['naziv']."</a>\n</li> \n"; } if(isset($menu['parents'][$itemId])) { $html .= " <li>\n <a >".$menu['items'][$itemId]['naziv']."</a> \n"; $html .= buildMenu($itemId, $menu); $html .= "</li> \n"; } } $html .= "</ul> \n"; } return $html; } echo buildMenu(0, $menu); ?> </BODY> </HTML> javascript part: $(document).ready(function(){ $('#accordion > li ul') .click(function(event){ event.stopPropagation(); }) .filter(':not(:first)') .hide(); $('#accordion > li, #accordion > li > ul > li').click(function(){ var selfClick = $(this).find('ul:first').is(':visible'); if(!selfClick) { $(this) .parent() .find('> li ul:visible') .slideToggle(); } $(this) .find('ul:first') .stop(true, true) .slideToggle(); }); }); This is image of what is happening
  10. Thank you for reply! i will search and try to pull this up!
  11. For question 3) i know that, my question was wrong, how to upload image to server and insert path in database... 4) how to do that? 5) No, i designed breadcrumb but now need to make it work, have front end, now i need to write back end for it in my head every question sound nice, but i see that is confusing...
  12. Hello everyone, like title says i want to ask you some questions about web shop. Recently i started to develop web shop (php and mysql based) and down the road i came to this problems: 1) All products and theirs data are stored in database and the question is how will google see it when i search for some product? How SEO work with database? 2) I will create web shop from scratch without any framework or CMS (i will create my own) so my second question is how to insert social plugins? I insert twitter and google plus on my other site (from theirs developing pages and they work nicely) but facebook like button doesnt work well for me and i dont know why...i did everything from here http://developers.fa...e/plugins/like/ count numbers arent correct, i have metatags, and facebook sdk on page...is there any plugin or class or something that has all social plugins on one place? 3) Every product has image, so i thought to store path into database, but when admin (someone who dont know lot of how that works and need to be very, very simple) want to insert new product it will be needed to create query that will insert image path, so how to create that query? 4) Web shop will have a lot of product, and groups of product so it will needed to be hierarchical database which is problem for me becouse i never done it It will have few levels and every level will have sublevels and some sublevels will have their sublevels..and some product will have to be in two or more groups 5) I create css breadcrumb but how to do background for it? I will appriciate some guidings Sorry for grammer mistakes english isnt my native language
  13. Hi everybody, i have class with some variables and insert function, but when i call insert function in database are inserted empty values, just id (AUTO INCREMENT) has value other cells are emtpy... My class is: <?php include ('db_fns.php'); class preduzece { public $naziv_preduzeca; public $sifra_mesta; public $ulica; public $broj; public $opis; public $sifra_delatnosti; public $sifra_usluge; public $aktivno; public function dodaj_preduzece ($preduzece) { $query = "INSERT INTO preduzece (naziv_preduzeca, sifra_mesta, ulica, broj, opis, sifra_delatnosti, aktivno) VALUES ('$preduzece->naziv_preduzeca','$preduzece->sifra_mesta','$preduzece->ulica','$preduzece->broj', '$preduzece->opis','$preduzece->sifra_delatnosti','$preduzece->aktivno')"; $result = mysql_query($query) or die("Doslo je do greske prilikom unosa preduzeca:" .mysql_error()); // insert } } ?> And in other page i use it (have form from witch i collect values for db): include("scripts/preduzece_fns.php") $firma=new preduzece() ; $firma->ulica=$_POST['ulica']; $firma->broj=$_POST['broj']; $firma->ulica= mysql_real_escape_string( $firma->ulica ); $firma->broj= mysql_real_escape_string( $firma->broj ); $firma->naziv_preduzeca = $_POST["naziv_preduzeca"]; $firma->naziv_preduzeca = mysql_real_escape_string( $firma->naziv_preduzeca ); $firma->sifra_mesta = $_POST["mesto"]; $firma->opis = $_POST["opis"]; $firma->opis= mysql_real_escape_string( $firma->opis ); $firma->sifra_delatnosti = $_POST["delatnost"]; $firma->aktivno = $_POST["aktivno"]; $firma->dodaj_preduzece(); when i echo $firma->naziv_preduzeca or anything else values are collected from form, only when i call function dodaj_preduzece something goes wrong... Does anybody know why this is happening? Ps sorry for grammar errors if i have it (I am from Serbia )
  14. @ManiacDan that is whole file, nothing else is in there...and that file is included... @PFMaBiSmAd i am not including it twice... Can you tell me how to print product name from database into title tag? is there other way? I don't know what to do...my way obviously doesn't work... Edit: I solved it...just puted if(!function_exists('connectToDB')) before function and it works...thank you all for helping me!
  15. I know that, but look at this... include('dblib.php'); connectToDB(); this is where he (php) thinks that is redeclared conectToDB... global $connection; function connectToDB() { global $connection; // this is line 9 $dbhost = 'localhost'; $dbuser = 'fitnes_5653'; $dbpass = 'test'; $connection = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); //$dbname = 'fitnes'; $dbname = 'fitnes_5653'; mysql_select_db($dbname); //return $connection; } // this is line 22 there shouldn't be error in here...
  16. Hi everyone, i have problem with printing something from database in title tag. This is code <title><?php $id_brenda = $_GET['id']; $query="SELECT * FROM brend WHERE id_brenda='$id_brenda'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo $row['naziv_brenda']; } ?></title> And i get this warning line 9 is $result = mysql_query($query) or die(mysql_error()); Does anyone know on what is meant with this warning? My connection on database is in separate file, and when i insert it in file with this code i get other error: Please help me, this error driving me crazy.
  17. Hy everybody, i have facebook share button on my site (in code) but on page is missing...this is code <a name="fb_share"></a> <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"> </script> Does anybody know why this missing on page?
  18. Hi guys, i wanna start e comerce webiste, this will be my first. So i just wanna ask you for some advices like on what to pay attention for, some security advices. It would be in php and mysql with css and javascript. I have on my mind what it would look like and i just need some directions and advices. It sholud be with my cms, and it should be implemented paying with card's what i should get from bank. Thank you in advance! Cheers
  19. Hi there, i'm wondering if this may be done somehow? Basically i have side navigation and i want to open links from it to central content div, so everything would be on same page. I hope that you understand what i am asking? Thank in advance. In attachment is image of how i imagind it.
  20. is there any simpler way to do that?
  21. hi guy's i have on one page select from table, and i don't know how to limit showing content from database on 3, and rest to make number under it and when i click on that number next 3 is showen? Something like on forum when you have more topics then you can show, on botom of page are showen numbers (links). Can some explain me how to do this? i put in while loop something like this while ($prom = mysql_fetch_object($res) and $i<3) and now it is limited on showing first 3, my problem is showing next 3, and if there is more how to split it on 3 per page?
  22. no,no,no i'm not so noob! that is for one table, and for other in same place? i have at login in some variable that contains email from loged user! now i need to check in some pages is it loged profesor or student! i need to check bot table to see who is loged! i solved it with session in witch i store value of role! if role is 2 it is student and i select student from table, else if 3 it is profesor and i select profesor...
  23. for example i have two tables in witch are students and profesors. when i log in i redirect students at theirs page and profesors on other page. but i have some pages that are same for both students and profesors. in some area of my page i have echo witch displays name of profesor/student! and now i need to check in both tables to find is it profesor or student and echo their name, i tried with num_rows, and that way dosnt work for me. the num_row counter is only to try to see if the table contains that value. and if contains i do select of it and echo names, but that way like i said doesn't work! i hope that now i better explaind what i need.
  24. i know that, i wrote that unconsciously...my problem isn't that, my problem is that mysql_num_rows must be > then 0, and if it is 0 there is error that say that...i must change somehow that if statement, but i dont know what to put in it...
  25. yes i mean check! sorry for that! i delete that part of my code because didn't work, i tried something like this $nesto="SELECT * FROM projekat WHERE naziv= '$value' "; $res=mysql_query($nesto); $num_rows = mysql_num_rows($resultat); if (num_rows>0) { //some code } else { $nesto="SELECT * FROM zadatak WHERE naziv= '$value' "; $res=mysql_query($nesto); $num_rows = mysql_num_rows($resultat); //and here again some code }
×
×
  • 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.