I'm trying to display results from my database, I didn't know how until I saw this way of doing it while($row=mysql_fetch_array($result) { //Code }
and then I saw that using this way is somewhat obsolete, so I would have to choose to use while($row = $query->fetch(PDO::FETCH_ASSOC)) { //Code }
. My problem is that I don't understand how the while works: At what point does it stop being true? What is the data that it iterates? In a nutshell, how does this code work?
Ricardo A's questions
While I was learning about the event loop in Node.js I heard the definition of ''multi threading'' and I really don't know what they mean or what they mean. If someone could explain it to me I would really appreciate it. First of all, Thanks.
I have seen that they talk a lot about entry points and end points, the truth is that I have an idea of what it refers to, but I still don't know the correct definition or what they are for. Beforehand thank you very much.
I'm learning about technologies in Frontend and I'm learning to use Browserify and I came across that they used the ''modular'' definition with Browserify. I hope someone can tell me what modular means and what it is for. Thanks in advance.
What I'm trying to do is have the text I enter in my modal appear in my h1 like this:
But instead it appears to me in this other way:
What is the problem? Here is my code: This is HTML
<p>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#nombralo">Nombra esta foto</button>
<div class="modal fade" tabindex="-1" role="dialog" id="nombralo">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Dale nombre a esta foto</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="message-text" class="control-label">Nombra la foto:</label>
<input type="text" class="form-control" id="message-text">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-primary" id="aceptar">Aceptar</button>
</div>
</div>
</div>
</div>
<h1></h1>
</p>
And this is the Javascript:
$(document).ready(function() {
$("#aceptar").click(function () {
$("#message-text").appendTo("h1");
})
});
I made a modal with Bootstrap and everything went exactly as I wanted, the only problem is that it appears right below the button that is supposed to make the modal appear, why does this happen? How can I solve it? Here I leave my code and an image of what is happening.
<p>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#nombralo">Nombra esta foto</button>
<div class="modal-fade" tabindex="-1" role="dialog" id="nombralo">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Dale nombre a esta foto</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="message-text" class="control-label">Nombra la foto:</label>
<input type="text" class="form-control" id="message-text">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-primary">Aceptar</button>
</div>
</div>
</div>
</div>
<h1></h1>
</p>
I have seen it a lot in HTML but I don't know exactly what it is for, help please
What I mean is that I have seen for example in Bootstrap you can either download it and put a like mini link in your text editor or you can just put a cdn link although it is a bit longer, and I have seen the same with Jquery , you can choose between putting a cdn link and downloading it. What is the difference and which one is more recommended to use?
Is that according to me both could be used for any kind of thing like in strings in variables, cycles, etc. For example:
var comillasDobles = "Ejemplo";
var comillasSimples = 'Ejemplo dos';
According to me this was the same, but I have seen in many places that sometimes they say "your code is wrong because you used double quotes and they should be single" and vice versa. Could someone explain the difference to me? please.
I know that doing this must be easy, but I really don't know how I could do it, I was working on it and I was investigating but I got stuck. It would help me a lot if someone could help me finish my code. Beforehand thank you very much.
function findLongestWord(str) {
var pp = str.split(" ");
return str.length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");
I have already divided the string into an array, the only thing I need is to know how to measure each word individually and know which is the one that measures more. At first I thought of using a for loop to go from word to word but after that I ran out of ideas, please help.
I know I have to use .reverse(); and I imagine that the first thing I have to do is also pass the string given in the parameter to an array, but I don't know how I could do it or in what order. I leave my code below.
function reverseString(str) {
return str;
}
reverseString("hello");
Beforehand thank you very much.
(What I want is that if I put "hello" as a parameter when returning the value it says "olleh").
This is an example of my doubt, why put "this" at the beginning instead of just putting "wheels = 4" or "seats = 1", etc. How can this help me when programming?
var Car = function() {
this.wheels = 4;
this.seats = 1;
this.engines = 1;
};
It's just that I'm learning for loops in Javascript but I got a for loop nested within another and I don't fully understand how this works. According to what I saw in a result, it is that one is multiplied by another (or something similar) but the truth is that I do not understand how it is multiplied or how this code works.
If I don't formulate my question correctly, tell me? Please.
Thanks in advance.
var arr = [[1,2], [3,4], [5,6]];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
$(document).ready(function() {
//Botones de la comida
var bon = document.getElementById('boton1');
bon.addEventListener("click", agregar1);
var bona = document.getElementById('boton2');
bona.addEventListener("click", agregar2)
//Funciones para agregar la comida al recuadro en blanco
function agregar1() {
$('<p>Hamburguesa - 50 pesos </p>').appendTo('#preciosC');
}
function agregar2() {
$('<p>pizza - 100 pesos</p>').appendTo('#preciosC');
}
});