Jump to content

thugsr

Members
  • Posts

    28
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

thugsr's Achievements

Member

Member (2/5)

0

Reputation

  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...
×
×
  • 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.