Jump to content

felito

Members
  • Posts

    92
  • Joined

  • Last visited

    Never

Everything posted by felito

  1. Hi This works to check the name attribute: <input type="hidden" name="submitted" value="TRUE" /> //On HTML Page if(isset($_POST['submitted'])) //PHP Check And if I want to check by id or class? thanks
  2. this solve my problem. http://jsfiddle.net/X9uvK/ thanks
  3. hi I am trying this code, but apparently something is wrong: <a class = "perfil_1"><h3>Luciana</h3> </a> <a class = "perfil_2"><h3>Luciana</h3></a> <a class = "perfil_3"><h3>Luciana</h3> </a> <div id="dialog_1"> <p>Lorem ipsum dolor sit amet</p> </div> <div id="dialog_2"> <p>Lorem ipsum dolor sit amet</p> </div> <div id="dialog_3"> <p>Lorem ipsum dolor sit amet</p> </div> for (var i = 1; i <= 4; i++) { $('#dialog_' + i).dialog({ autoOpen: false, show: "slide", hide: "explode" }); $('.perfil_' + i).on("click", "h3" , function () { $('#dialog_'+i).dialog('open'); return false; }); } http://jsfiddle.net/JbFZD/ > any idea?
  4. This is a simple demo about my problem. I need to access the id_user in main.js file. My question is, how to avoid global variables in this situation? It is bad practice use global variables for this purpose? main.js require({ paths : { jQuery : 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min' } }); require([ 'jQuery' ], function() { alert(id_user); }); index.php <script data-main="js/main" src="js/require.js"></script> <script type="text/javascript"> function users() { id_user = <?php echo $id; ?> } users(); </script>
  5. yes, random or ordered alphabetically. This query is more difficult than I thought. :-\ thanks
  6. To clarify. I have this structure: table users id_user username update_photo 1 Pedro photo 2 Joao photo 3 Carlos photo 4 José photo 5 António photo 6 Toni photo table lists id_lists name_list users_id_user 1 primeira_lista 9 // owner of the list 2 segunda_lista 9 // owner of the list table lists_has_users users_id_user lists_id_lists 1 1 - first 2 1 - second 3 1 -------- 4 2 - first 5 2 - second 6 2 -------- The outuput that I want is: 1 Pedro photo 2 Joao photo 3 Carlos photo 4 José photo 5 António photo 6 Toni photo My idea is a sample of two members of each list. If the user want to see more members he can click in view more button that will open a new page with all members of this list. Did you understand what i mean?
  7. I am trying this code, that works well. SELECT U.username, U.update_photo FROM users U INNER JOIN lists_has_users H ON U.id_user = H.users_id_user INNER JOIN lists L ON L.id_lists = H.lists_id_lists WHERE L.users_id_user = ? Now the problem. This query will select all the users of the lists. What i want is limit the number of output members by list. For example, two members by each list (id_lists). Any idea? thanks
  8. thanks man, Works perfectly.
  9. thanks to all. The main problem is that the order of the index is not the natural. array 0 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 1 => array 1 => int 1 2 => string 'D' (length=1) 3 => string 'E' (length=1) 2 => array 2 => int 1 3 => string 'F' (length=1) is different of: array 0 => array 0 => string 'A' (length=1) 1 => string 'B' (length=1) 2 => string 'C' (length=1) 1 => array 0 => string 'D' (length=1) 1 => string 'E' (length=1) 2 => array 0 => string 'F' (length=1) this solves the issue, but i have problems with the ceil in some cases. $nArr = array('A', 'B', 'C', 'D', 'E', 'F'); $lp = 3; for ($i = 0; $i < $lp; $i++) { $m[$i][$i] = 1; for ($x = $i; $x < $lp; $x++) { $v = $i+ceil($i/2); $m[$i][$x+1] = $nArr[$x+$v]; } }
  10. Well, as i said, i need this structure: array 0 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 1 => array 1 => int 1 2 => string 'D' (length=1) 3 => string 'E' (length=1) 2 => array 2 => int 1 3 => string 'F' (length=1) How ksort can be useful?
  11. I have this code $nArr = array('A', 'B', 'C', 'D', 'E', 'F'); $counter = 3; while ($counter > 0) { $chunkedValues[$counter][0] = 1; for ($j = 0 ; $j < $counter ; $j++) { $chunkedValues[$counter][$j + 1] = $nArr[$j]; } $nArr = array_slice($nArr, $counter--); } var_dump($chunkedValues); that outputs: array 3 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 2 => array 0 => int 1 1 => string 'D' (length=1) 2 => string 'E' (length=1) 1 => array 0 => int 1 1 => string 'F' (length=1) But i need this index structure: array 0 => array 0 => int 1 1 => string 'A' (length=1) 2 => string 'B' (length=1) 3 => string 'C' (length=1) 1 => array 1 => int 1 2 => string 'D' (length=1) 3 => string 'E' (length=1) 2 => array 2 => int 1 3 => string 'F' (length=1) I want to avoid loops with ceil. Any idea? thanks for your time.
  12. should be $str and count($arr_tags);. Anyway, the problem is not that.
  13. hi What is the correct way to do a function like: public function check_($db, $skills) { $arr_tags = array('16', '17', '36', '546'); $z = implode(', ', array_fill(0, count($arr_tags), '?')); $str = implode('', array_fill(0, count($arr_tags),'s')); $par = "'" . implode("','", $arr_tags) . "'"; $c_arr_tags = count($arr_tag); $sql = $db -> prepare(" SELECT offer_id_offer FROM offer_has_tags WHERE tags_id_tags IN ($z) GROUP BY offer_id_offer HAVING COUNT(*) = ? "); $sql -> bind_param("$srt.'i'", $par, $c_arr_tags); $sql -> execute(); $sql -> bind_result($id_offer); return $id_offer; } At the moment i got: Number of elements in type definition string doesn't match number of bind variables
  14. I am trying to use jquery to load a dojo chart. I am using this code. However in the second click, in the first button i get this error. The same occurs if i click in the first button, click in the second and click again in the first. This problem is Driving me crazy. http://i.stack.imgur.com/5ZmtM.jpg demo here http://74.52.141.77/~dnsmont/test1/ <script type="text/javascript"> $(document).ready(function () { $('.lista_').click(function () { $.get('index1.php', function (data) { dojo.addOnLoad(function () { require(["dojo/_base/xhr", "dojo/parser", "dojo/dom"], function (xhr, parser, dom) { var um = []; dijit.registry.filter(function (w) { //problem here, maybe this code destroy something that should not be destroyed if (dojo.indexOf(um)) { w.destroyRecursive(); } }); $('#paginas').html(data); dojo.parser.parse(dojo.byId('paginas')); }); }); }); }); }); </script>
  15. hi This var_dump give me false. So, my question is why this url is not valid ? thanks link http://00.00.000.00/~dnsmont/login/?se=home $url=$_SERVER['REQUEST_URI']; var_Dump(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED | FILTER_FLAG_QUERY_REQUIRED));
  16. this solve my problem SELECT A.id_offer, T.tags FROM ( SELECT * FROM offer WHERE state = 0 ORDER BY date DESC LIMIT 10 ) A JOIN offer_has_tags Z ON A.id_offer = Z.offer_id_offer JOIN tags T ON Z.tags_id_tags = T.id_tags
  17. I would like to know how can i limit the output by the number of id_offers and not the number of rows. For example SELECT A.id_offer, T.tags FROM offer A INNER JOIN offer_has_tags Z ON A.id_offer = Z.offer_id_offer INNER JOIN tags T ON Z.tags_id_tags = T.id_tags WHERE state = 0 ORDER BY date DESC LIMIT 0, 10 output: id_offer tags 77 xx 76 xx 76 xx 75 xx 75 xx 74 xx 74 xx 73 xx 73 xx 72 xx
  18. I need to pass two parameters in each() method. How can i do that ? The problem is this: I have a query that returns username, id, local, offer, and so on. But i need another function because i need to get the tags for each offer. The main problem is each offer can get many tags, so for each offer i need data from two php functions. script first function function get_posts($db, $start, $number_of_posts) { //code return json_encode($posts); } output: string '[{"username":"Altitude software","foto_oferta":"thumb\/miniaturas\/oferta\/default_offer.jpg","actividades":"Some activities","id_oferta":77,"oferta":"Programador web" ... second function function get_posts1($db, $start, $number_of_posts) { //code return json_encode($posts1); } output: string '[{"id_offer":77,"tags":["c++","JAVA"]},{"id_offer":76,"tags":["ajax","php"]},{"id_offer":75,"tags":["PHP","JAVA"]}]' js var postHandler = function(postsJSON, postsJSON1) { $.each(postsJSON, postsJSON1, function(i, post, post1) {//problem here- this didn't works. Only works something like $.each(postsJSON, function(i, post) { var id = 'post-' + post.id_oferta; $('<div></div>').addClass('post').attr('id',id) .html('<div class="box_offers"><div class="rating_offer"></div><div class="post-title">' + post.oferta + '</div> <div class="post-box"> <a class="oferta_val bold_username">' + post1.tags+ '</a></div><a id='+id+'hide class="post-more" >Tags</a><div class="logo_offer">') .appendTo($('#posts')); $('#'+id+'hide').click(function() { $('.'+id+'hidden').slideToggle('fast'); }); }); }; postHandler(<?php echo get_posts($db, 0, $_SESSION['posts_start']); ?>, <?php echo get_posts1($db, 0, $_SESSION['posts_start']); ?>);
  19. I have this code, but when I clone an element, then the action is also cloned. What i want is just individual actions for each element.You can see the problem in demo <script type="text/javascript"> $(document).ready(function() { $('.edit').editable('http://save.php', { indicator : 'Saving...', submit : 'OK', cancel : 'Cancelar', }); }); $(document).ready(function () { $('#btnAdd').live('click', function(){ var num = $('.clonedInput').length; var newNum = new Number(num + 1); var newElem = $('#input' + num).clone(true).prop('id', 'input' + newNum); newElem.children(':text').prop('name', "myformdata[job][]").prop('job', 'job').val(''); $('#input' + num).after(newElem); $('#btnDel').prop('disabled', ''); if (newNum == 4) $('#btnAdd').prop('disabled', 'disabled'); }); $('#btnDel').live('click', function(){ var num = $('.clonedInput').length; $('#input' + num).remove(); $('#btnAdd').prop('disabled', ''); if (num - 1 == 1) $('#btnDel').prop('disabled', 'disabled'); }); $('#btnDel').prop('disabled', 'disabled'); }); </script> <div class="clonedInput" id="input1"> <span style="float: left;">job</span> <div class="edit" id="job="myformdata[job][]">Job</div> </div> <div id="copy"> <input class="format" type="button" id="btnAdd" value="Ad" /> <input class="format" type="button" id="btnDel" value="Re" /> </div> http://jsbin.com/unebex/8/edit#preview
  20. i change to php 5.3 and the problem disappear
  21. hi i have this code: //sql $sql -> bind_param('s',$offer); $sql -> execute(); $sql -> bind_result($oferta, $cargo, $conteudo, $tipo_oferta, $local); $arr = array(); while ($sql -> fetch()) { $arr[] = array($oferta, $cargo, $conteudo, $tipo_oferta, $local); }; return $arr; then i make this in ajax (jquery) data: 'all=<?php echo json_encode($arr); ?>', and in other page i make: $editar = $_POST['all']; $e = json_decode($editar, true); echo $e[0][0]; the problem is: if i only do : $arr[] = array($oferta); this echo $e[0][0]; outputs: designer (is the value of $oferta) but if i do $arr[] = array($oferta, $cargo, $conteudo, $tipo_oferta, $local); echo $e[0][0]; simply doesn't show anything. the question is why ? and how can be solved?
  22. hi i have this code: $something ="text"; <script type="text/javascript"> $(document).ready(function() { $("#custom").submit(function() { var formdata = $("#custom").serialize(); $.ajax({ url: "dojo/insert.php", type: "post", dataType: "json", data: formdata, success: function(data) { switch (data.livre) { case 'valorLivre': $("#msg").fadeTo(200, 0.1, function() { $(this).html('Deve fazer a ponderação de competências!').fadeTo(900, 1); }); break; default: $("#msg").fadeTo(200, 0.1, function() { $(this).html('Oferta colocada!').fadeTo(900, 1); $.ajax({ url: "oferta.php", type: "post", dataType: "json", data:{ name:<?php echo $something; ?> //problem here }, success: function(data) { $('#total').load('oferta.php'); } }); }); break; } } }); return false; }); }); </script> when i run the page i get text is undefined. What is wrong in this code ? thanks
  23. thanks for your time xyph.
  24. is not an unique id ? I read that is also typically used for unique ID's. This information is wrong ? http://docstore.mik.ua/orelly/webprog/pcook/ch03_14.htm
×
×
  • 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.