When I copy data using Goolge Scripts it skips rows Is there a work around?

I have tried looping to just remove the cells I wanted but that didn’t work, I have also tried adjusting how it looks at the cells in a range but and just messed around with everything i could find and think of but to no avail this is the closest thing I can get to. My goal is to copy data from one sheet to another based off of a specific value and it all look like I entered them in row by row with no skipping.


    function tranferData(){
      var today = new Date(getCurrentMonth());
      var ss=SpreadsheetApp.getActive();
      var sht=ss.getSheetByName('Sheet1');
      var sht2=ss.getSheetByName('Sheet2');
      var lastRow=sht.getLastRow();
      var lastColumn=sht.getLastColumn();
      var rng=sht.getRange(1,1,lastRow,lastColumn);
      var rngA=rng.getValues();
      for(var i=0;i<rngA.length;i++)
      {
        var test = rngA[i][2];
        if(test < today  && test != null && test != 0)
        {
          sht2.getRange(i+1,1).setValue(rngA[i][0]);
          sht2.getRange(i+1,2).setValue(rngA[i][1]);
          sht2.getRange(i+1,3).setValue(rngA[i][2]);
          sht2.getRange(i+1,4).setValue(rngA[i][3]);
        }
      }
      SpreadsheetApp.flush();
    }

Class not working when changed to functional component

I just cannot figure this one out. I think it’s to do with how I set my state in the ‘toggleTheme’ function.
I’m sorry if I don’t fit the styling for a post, I find I always make an oversight. Also, I have looked through the similar questions and tried their solutions but for some reason it just still will not work. I’ve actually made the project in codesandbox but I don’t know how to make it a non live link, ugh.

The working code:

import React, { createContext, Component } from 'react';

export const ThemeContext = createContext();

class ThemeContextProvider extends Component {
  state = {
    isLightTheme: true,
    light: { syntax: "#48527d", ui: "#a997af", bg: "#cee7e4" },
    dark: { syntax: "#bbbccf", ui: "#7b8ab2", bg: "#48527d" }
  }

  toggleTheme = () => {
    this.setState({ isLightTheme: !this.state.isLightTheme});
  }

  render() {
    return (
      <ThemeContext.Provider value={{...this.state, toggleTheme: this.toggleTheme}}>
        { this.props.children }
      </ThemeContext.Provider>
    );
  }
}

export default ThemeContextProvider;

This code will work as seen in the screen shots I posted on imgur link

When I change it to a functional component, I have a myriad of errors, which is shown in the imgur link at the top or bottom of the page:

import React, { createContext, Component, useState } from "react";

export const ThemeContext = createContext();

const ThemeContextProvider = (props) => {
  const [theme, setTheme] = useState({
    isLightTheme: true,
    light: { syntax: "#48527d", ui: "#a997af", bg: "#cee7e4" },
    dark: { syntax: "#bbbccf", ui: "#7b8ab2", bg: "#48527d" },
  });

  const toggleTheme = () => {
    setTheme({
      isLightTheme: !theme.isLightTheme,
    });
  };

  return (
    <ThemeContext.Provider value={{ ...theme, toggleTheme: toggleTheme }}>
      {props.children}
    </ThemeContext.Provider>
  );
};

export default ThemeContextProvider;

I cannot figure out why it’s throwing these errors. Perhaps I’m not thinking hard enough about it but I’m starting to lose it a little bit here.

I’m going to re-list the resources for convenience here at the bottom:

Interactable Code: codesandbox

Screenshots of outcomes and errors: link

Discord Bot is auto stopping

My discord bot is auto stopping for some reason. It turns off after around an hour of inactivity. I don’t know what code to send for that so if you need code to answer the question tell me and I will post which files you need.
Thanks

How to upload a file using formGroup in angular

my api works fine, it uploads, edits and deletes images, but my front-end doesn’t works, when i try to upload an image it shows me an error, here is my code:

export class CrearProductoComponent implements OnInit {

  productoForm: FormGroup;
  titulo = 'Crear Produto';
  id: string | null;
  uploadedFiles!: File;
  imagen_Form!: any;

  constructor(private fb: FormBuilder, 
              private router: Router, 
              private toastr: ToastrService, 
              private _productoService: ProductoService,
              private aRouter: ActivatedRoute) { 
     this.productoForm = this.fb.group({
       producto: ['', Validators.required],
       categoria: ['', Validators.required],
       ubicacion: ['', Validators.required],
       precio: ['', Validators.required],
       imagen: ['']
     })
     this.id = this.aRouter.snapshot.paramMap.get('id');
  }

  ngOnInit(): void {
    this.esEditar();
  }

  onFileChange(e: any) {
    /*
    const formData = new FormData();
    this.uploadedFiles = e.target.files
    const file = e.target.files
    */
    if (e.target.files.length > 0) {
      const file = e.target.files[0];
      this.uploadedFiles = file;
    }
    /*
    formData.append('imagen', file);
    this.productoForm.patchValue({ imagen: formData });
    this.productoForm.updateValueAndValidity();
    */

  }

  agregarProducto(){
    console.log(this.productoForm);
    console.log(this.productoForm.get('producto')?.value);

    const PRODUCTO: Producto = {
      nombre: this.productoForm.get('producto')?.value,
      categoria: this.productoForm.get('categoria')?.value,
      ubicacion: this.productoForm.get('ubicacion')?.value,
      precio: this.productoForm.get('precio')?.value,
      imagen: this.uploadedFiles
    };

    if(this.id !== null){
      this._productoService.actualizarProducto(PRODUCTO, this.id).subscribe(data => {
        this.toastr.success('Producto actualizado', 'Producto actualizado');
        this.router.navigate(['/']);
      }, error => {
        console.log(error);
      })
    } else {
      console.log(PRODUCTO);
      this._productoService.guardarProducto(PRODUCTO).subscribe(data => {
        this.toastr.success('El producto fue registrado con exito!', 'Producto Registrado');
        this.router.navigate(['/']);
      }, error => {
        console.log(error);
        this.productoForm.reset();
      })
    }
  }

  esEditar(){
      if(this.id !== null){
        this.titulo = 'Editar Producto';
        this._productoService.obtenerProducto(this.id).subscribe(data => {
          this.productoForm.setValue({
            producto: data.nombre,
            categoria: data.categoria,
            ubicacion: data.ubicacion,
            precio: data.precio
          })
        })
      }
  }

}

i have visit many pages and still not getting an answer or a guide, i could do it with formData, but is there any method to do it with a class model and formGroup?

also this my error

error

error 2

it worked in postman but not in my front-end.

Javascript Queues, confused

just wondering what this means in the queue in javascript —
const item = this.queue[this.headIndex]; I am bit confused why the [this.headindex] needs to be here.

function Queue() {
  //create new array
  this.queue = new Array();
  //head set at 0
  this.headIndex = 0;
  //tail set at 0
  this.tailIndex = 0;

  Queue.prototype.enqueue = function (element) {
    //adds to queue with an tail index
    this.queue[this.tailIndex] = element;
    //add 1 to tail eachtime run
    this.tailIndex++;
  };
  Queue.prototype.dequeue = function () {
    //if 0 return undefined
    if (this.length() <= 0) {
      return undefined;
    }
    //var equal
    const item = this.queue[this.headIndex];
    //removes first el from queue
    delete this.queue[this.headIndex];
    // increments head by everytime run
    this.headIndex++;
    return item;
  };
  Queue.prototype.length = function () {
    //subtracts both vals to get length of queue
    return this.tailIndex - this.headIndex;
  };
  Queue.prototype.look = function () {
    //shows whats in queue
    return this.queue;
  };
}

just learning coding, so any explanation would be greatly appreciated.

thanks

How can I use just one on(change) function with multiple sliders?

I have multiple noUISliders and I am wanting to have one on(change) function for all of them instead of one for each slider. The on(change) will essentially trigger the same function. Basically it will be some math that will add all the values of the sliders. Do I have to do a loop? I just have an alert in there for testing.

    var slider = $('#slider');
    var slider = slider[0];

    noUiSlider.create(slider, {
        animate: true,
        start: 41,
        step: 5,
        tooltips: [wNumb({decimals: 0})],
        connect: 'lower',
        range: {
            'min':0,
            'max': 1000
        }
    });


    var slider2 = $('#slider2');
    var slider2 = slider2[0];

    noUiSlider.create(slider2, {
        animate: true,
        start: 20,
        step: 1,
        tooltips: [wNumb({decimals: 0})],
        connect: 'lower',
        range: {
            'min':0,
            'max': 100
        }
    });


    var slider3 = $('#slider3');
    var slider3 = slider3[0];

    noUiSlider.create(slider3, {
        animate: true,
        start: 20,
        step: 1,
        tooltips: [wNumb({decimals: 0})],
        connect: 'lower',
        range: {
            'min':0,
            'max': 100
        }
    });

$('#slider')[0].noUiSlider.on('change',function(v,handle){

    alert("slider triggered");

});

The best way to follow an Ethereum (BSC) address and all its new transactions

I am currently developing a Binance Smart Chain wallet. It has around 50k active users. But I am facing an issue, when an user receives BNB or BEP-20 tokens, he does not know about it until he manually checks his balance.
So my question is : how to notify the user about every new transaction to his address at least every 20 minutes (and that’s long I thing).
I’ve seen there are apis for that, but they are too expensive. Also I can’t manually check balance with a node provider. Since it will be hundreds of millions requests every month…
I guess I have to deploy my own Binance Smart Chain node and write some script to subscribe to addresses. But how much can it cost with all these requests? Are there some docs on that?
Thank you!

multiple buttons in one ActionRow

I’m using the discord.js library and node.js to create a Discord bot that can send a DM to a user containing buttons.

I want to send a Discord message with multiple buttons, each with a unique customId and label. My current method is using an list of buttons. I use a for loop adding button objects to the list, and pass it in to the components of the .send method as a list.

x = 5
buttons = []

for (let i = 0; i < x; i++) {
    buttons.push(new MessageActionRow().addComponents(
        new MessageButton()
            .setCustomId(i.toString())
            .setLabel(messageSplit[i])
            .setStyle('PRIMARY')
        )
    )
}

msg.reply({ embeds: [embedRecipient], components: buttons })

This works, but each button is an new ActionRow of its own and thus resulting in the buttons being on different lines. What I mean: image of buttons each on a different line

How can I make it so the same features (like customId and Label) of the buttons retain but they are all on the same line? Making them all in the same one ActionRow should solve this I don’t know the code to achieve that.

How do i make a Horizontal Timeline Bar using html and css

I am making a timeline where i put first images
Images
after that i make a line where i place button

enter image description here

i am trying to make a csss where like which ever i click this circle a coloured should come across it. like timeline menu.
For example if i want to click cartoon button then a the below line should come with colour and filled with that. like this but not happening with my logic. How should i

https://codepen.io/mohit-04/pen/abWPwPq

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="head">
        <ul class="nav">
          <li class="st st1 active">
            <img
              src="https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Y2FydG9vbnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=600&q=60"
              alt="" class="profile" checked
            />
            <p>Minions</p>
          </li>
          <li class="st st2">
            <img
              src="https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTN8fGNhcnRvb258ZW58MHx8MHx8&auto=format&fit=crop&w=600&q=60" class="setting"
              alt=""
            />
            <p>Happy</p>
          </li>
          <li class="st st3">
            <img
              src="https://images.unsplash.com/photo-1638803040283-7a5ffd48dad5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NDF8fGNhcnRvb258ZW58MHx8MHx8&auto=format&fit=crop&w=600&q=60"
              alt="" class="posts"
            />
            <p>Cartoon</p>
          </li>
          <li class="st st4">
            <img
              src="https://images.unsplash.com/photo-1637855463319-9acb4e5aa44f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NDl8fGNhcnRvb258ZW58MHx8MHx8&auto=format&fit=crop&w=600&q=60"
              alt="" class="books"
            />
            <p>Cat</p>
          </li>

          <li class="st st5">
            <img
              src="https://images.unsplash.com/photo-1578632767115-351597cf2477?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8YW5pbWV8ZW58MHx8MHx8&auto=format&fit=crop&w=600&q=60"
              alt="" class="extra"
            />
            <p>anime</p>
          </li>
        </ul>
        <div class="line">
          <span></span>
        </div>
      </div>
      <div class="content">
        <section class="minion-section">
          <span><i></i></span>
          <h1>Minion</h1>
          <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate
            quaerat quos eligendi distinctio velit. Id, a, amet, similique saepe
            quaerat quam veniam suscipit exercitationem ut quidem odio?
            Necessitatibus, velit recusandae.
          </p>
        </section>
        <section class="happy-section">
            <span><i></i></span>
            <h1>Happy</h1>
            <p>
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate
              quaerat quos eligendi distinctio velit. Id, a, amet, similique saepe
              quaerat quam veniam suscipit exercitationem ut quidem odio?
              Necessitatibus, velit recusandae.
            </p>
          </section>
          <section class="cartoon-section">
            <span><i></i></span>
            <h1>Cartoon</h1>
            <p>
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate
              quaerat quos eligendi distinctio velit. Id, a, amet, similique saepe
              quaerat quam veniam suscipit exercitationem ut quidem odio?
              Necessitatibus, velit recusandae.
            </p>
          </section>
          <section class="cat-section">
            <span><i></i></span>
            <h1>Cat</h1>
            <p>
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate
              quaerat quos eligendi distinctio velit. Id, a, amet, similique saepe
              quaerat quam veniam suscipit exercitationem ut quidem odio?
              Necessitatibus, velit recusandae.
            </p>
          </section>
          <section class="anime-section">
            <span><i></i></span>
            <h1>Anime</h1>
            <p>
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate
              quaerat quos eligendi distinctio velit. Id, a, amet, similique saepe
              quaerat quam veniam suscipit exercitationem ut quidem odio?
              Necessitatibus, velit recusandae.
            </p>
          </section>
      </div>
    </div>
  </body>
</html>

style.css

@import url('https://fonts.googleapis.com/css2?family=Epilogue:wght@200&display=swap');

*{
    padding: 0 ;
    margin: 0;
}

body{
    background-position: center;
    font-family: 'Epilogue', sans-serif;
}

img{
    width: 80px;
}

ul {
    text-align: center;
}

ul li {
    display: inline-block;
    width: 200px;
    text-transform: uppercase;
    font-weight: 700;
    transition: all .3s ease;
    position: relative;
}

.container{
    margin: 50px auto;
    width: 80vw;
}

ul.nav li .inner{
position: absolute;
width: 100%;
font-size: 14px;
font-weight: bold;
}

ul.nav li.active,
ul.nav li:hover{
    color: #444;
}

ul.nav li::after{
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    background: #777;
    border-radius: 50%;
    margin: auto;
    border: 7px solid #fff;
    margin-top: 40px;
    box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, .2);

}

ul.nav li:hover::after,
ul.nav li.active::after{
    background: blue;
}

.line{
    width: 76%;
    margin: auto;
    background: #eee;
    height: 7px;
    position: absolute;
    left: 11.5%;
    top: 41%;
    z-index: -1;
    border-radius: 50px;
}

.line span {
    content: '';
    width: 2;
    height: 100%;
    background-image: linear-gradient(to right, #282d35 0%, #282d35 100%);
    position: absolute;
    z-index: 2;
    border-radius: 50px;
    transition: all .8s ease;
}

.content{
    position: relative;
    display: flex;
    justify-content: center;
    animation: anim .7s linear forwards;
    flex-direction: column;
}

section {
    /* padding-top: 400px; */
    justify-content: center;
    width: 70%;
    margin: 50px 25px 25px 125px;
    background-image: linear-gradient(to right, #282d35 0%, #282d35 100%);
    border-radius: 4px;
    /* padding: 20px; */
    /* padding-top: 10px;
    padding-left: 10px; */
    color: #fff;
}

section span {
    font-size: 3rem;
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

section h1{
    font-weight: 900;
    margin-top: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bolder;
}

section p{
    padding: 30px 40px;
    text-align: center;
    /* font-weight: bold; */
    font-size: 18px;
}

.profile:checked ~ .head .nav li.st1::before,

.settings:checked ~ .head .nav li.st1::before,
.settings:checked ~ .head .nav li.st2::before,

.posts:checked ~ .head .nav li.st1::before,
.posts:checked ~ .head .nav li.st2::before,
.posts:checked ~ .head .nav li.st3::before,

.books:checked ~ .head .nav li.st1::before,
.books:checked ~ .head .nav li.st2::before,
.books:checked ~ .head .nav li.st3::before,
.books:checked ~ .head .nav li.st4::before,

.extra:checked ~ .head .nav li.st1::before,
.extra:checked ~ .head .nav li.st2::before,
.extra:checked ~ .head .nav li.st3::before,
.extra:checked ~ .head .nav li.st4::before,
.extra:checked ~ .head .nav li.st5::before{
    border: 2px solid #fff;
    background: #777;
    transition: all .3s ease;
}

.settings:checked ~ .head .line span{
    width: 35%;
}

How do I target a previous Element child by that is further back than just the previous element?

The problem I am having is targeting the text in the input tag in the HTML below with Button that is Copying that text (words). What do i need to change to the JS to get it to target that Input value?

I want to do this without using ID – as I plan on replicating this many many times and don’t want to set up individual Id’s for the Input tags.

If there is a way to refer to the Class – ‘columns-small-8’ – child element, then maybe that would work?

Thanks in advance

JS

<script> 

window.onload=function(){
let btns = document.getElementsByTagName("button")
Array.from(btns).forEach(ele => {
  ele.addEventListener("click", function() {
   jimsFunction(this)
  });
})  
function jimsFunction(input) {
  let x = input.previousElementSibling
  let ele = x.previousElementSibling
  ele.select()
  ele.setSelectionRange(0, 99999)
  navigator.clipboard.writeText(ele.value)
  alert("Copied: " + ele.value)
}}

</script>

HTML

       <div>
          <div class="row collapse">
            <div class="columns small-8">
              <input type="text" value="words" readonly>
            </div>
            <div class="columns small-2">
              <a class="button full-width secondary" href="www.google.com" 
              target="_blank">View</a>                                
            </div>
            <div class="columns small-2">
              <button type="button" class="button full-width secondary">Copy URL</button>
            </div>
          </div>
        </div>

Issues with SVG objects on Mobile

I have tried everything but I think I’m just a bit over my head here. I have created a site that on desktop works perfectly, but, on mobile, the hover elements just will not work. I’m using SVG Objects.

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>F1 2021: Round 22 Abu Dhabi Grand Prix</title>
</head>

<body>

<style>
.circuit-map {
position: relative;
background-image: url(/circuits/round-01/bahrain.svg);
background-position: center;
overflow: hidden;
background-size: cover;
}
.circuit-map > img {
    display: block;
    width: 100%;
    height: 100%;
    
}

.circuit-map .circuit-controls {
    position: absolute;
    overflow: hidden;
    display: flex;
    transition: 0.3s;
    cursor: pointer;
}
.circuit-map .circuit-controls img {
    display: none;
    width: calc(100%);
    min-width: calc(100%);
}

.circuit-map .circuit-controls#statsLeft,
.circuit-map .circuit-controls#statsRight {
    top: 0;
    width: 4%;
    height: 84%;
    margin: 4.4% 0;
}
.circuit-map .circuit-controls#statsLeft {
    left: 0;
    flex-direction: row-reverse;
}
.circuit-map .circuit-controls#statsRight {
    right: 0;
}

.circuit-map .circuit-controls#statsLeft:hover,
.circuit-map .circuit-controls#statsRight:hover {
    width: 95.65%;
}

.circuit-map .circuit-controls#statsTop,
.circuit-map .circuit-controls#statsBottom {
    left: 0;
    height: 7.5%;
    width: 91.5%;
    margin: 0 4.25%;
}

.circuit-map .circuit-controls#statsTop {
    top: 0;
    flex-direction: column-reverse;
}
.circuit-map .circuit-controls#statsBottom {
    bottom: 0;
    flex-direction:column;
}

.circuit-map .circuit-controls#statsTop:hover,
.circuit-map .circuit-controls#statsBottom:hover {
    height: 92.1%;
}

</style>

<header>
<hr style="height:1px;background-color:white">
<h1>Round 01 Bahrain Grand Prix</h1>
<h2 style="font-size: 36px;">Sakhir Circuit, Bahrain</h2>
<br>
<h2>31 Dec, 2021</h2>

</header>
<br>
<br>
<section class="container">
<div class="circuit-map">
<img
id="circuitImage"
src="circuit.svg"
alt="Sakhir Circuit, Bahrain"
/>
<div class="circuit-controls" id="statsLeft">
<object type="image/svg+xml" data="starting-grid.svg"></object></div>
<div class="circuit-controls" id="statsRight">
<object type="image/svg+xml" data="race-results.svg"></object></div>
<div class="circuit-controls" id="statsBottom">
<object type="image/svg+xml" data="sprint-results.svg"></object></div>
<div class="circuit-controls" id="statsTop">
<object type="image/svg+xml" data="stats-top.svg"></object></div>
</div>

<script>
const circuitImageDOM = document.getElementById('circuitImage');

function calculateStatsSizes() {
const statsXDOM = [
document.querySelector('#statsLeft object'),
document.querySelector('#statsRight object'),
];
const statsYDOM = [
document.querySelector('#statsTop object'),
document.querySelector('#statsBottom object'),
];

const parentSizes =
statsXDOM[0].parentElement.parentElement.getBoundingClientRect();
const parentWidth = parentSizes.width;
const parentHeight = parentSizes.height;

statsXDOM.forEach(stat => {
stat.style.minWidth = `${parentWidth}px`;
stat.style.display = 'block';
});
statsYDOM.forEach(stat => {
stat.style.minHeight = `${parentHeight}px`;
stat.style.display = 'block';
});
}
circuitImageDOM.addEventListener('load', calculateStatsSizes);
window.addEventListener('resize', calculateStatsSizes);

circuitImageDOM.setAttribute(
'src',
`${circuitImageDOM.getAttribute(
'src'
)}?preventCache=${Math.random()}`
);
</script>
</body>

</html>

I just cannot seem to get this working on mobile – as a reference, here is the published site https://drivetodescribe.com/circuits/round-01/index.html. Can anyone help with this?

JS heap out of memory: Determining how much memory application needs

I have an application that reads from JSON files and adds the data to a Kafka producer. As we’re dealing with 5MB/s I needed to multithread this process. I have 3 workers reading files and 7 workers writing to Kafka. However, no matter what I do I keep getting the same error.

FATAL: Error: Worker terminated due to reaching memory limit: JS heap out of memory
    at new NodeError (node:internal/errors:372:5)
    at Worker.[kOnExit] (node:internal/worker:276:26)
    at Worker.<computed>.onexit (node:internal/worker:198:20) {
  code: 'ERR_WORKER_OUT_OF_MEMORY'
}

I’ve changed how much heap space (up to 16GB!) Javascript runs with by setting

NODE_OPTIONS=--max-old-space-size=$((16 * 1024))

But no matter what I do I keep running out of memory after around 20 minutes or so. How can I make sure I don’t run out of memory?

Filling an array to use as a parameter for WHERE clause [duplicate]

I’m trying to fetch all of the position_id’s in order to fill an array which I can then pass to the second statement to fetch all of the rows containing a position_id in the array. I’m trying to use this data to fill a dropdown menu.

Am I doing this properly or is there a better way to do this?

// $_POST['aid'] == election_id
if(isset($_POST['aid'])) {
    // Get's the rows with corresponding election_id 
    $stm = $db->prepare("SELECT * FROM position_elections WHERE election_id = " . $_POST['aid']);
    $stm->execute();
    $position_ids = [];
    if ($row = $stm->fetchAll(PDO::FETCH_ASSOC)) 
    {
        $position_id = $row['position_id'];
        array_push($position_ids, $position_id);
    }

    $ids = join("','",$position_ids);
    $stm2 = $db->prepare("SELECT * FROM positions WHERE position_id IN ($ids)");
    $stm2->execute();
    $positions = $stm2->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode($positions);

}