0

I have a page that lists output from the database. I am using a div tag to list the output of each row. I would like to have only ten items outputted on a page, so I will be adding "next" and "previous" buttons to page the results. I don't necessarily want to refresh the whole browser window, just the div section. Is there a way to do this using only HTML and CSS? My code is below. I am developing using Node.js, thanks.

app.js

router.get('/profile',  function(req, res, next) {
  db.query('SELECT  city_name, state_name, party_name, price, image, address, full_name  FROM register natural join party where userid = id', function (err, rs) {
    if(!err){
    res.render('profile', {party: rs});
    }
    else{
    res.send(err);
    }
  });
});

profile.ejs

    <section class="gallery">
      <div class="prices">
        <h4>Search Results</h4>
        <% party.forEach(function(item) { %>
          <div class="img">
            <img src="/<%= item.image %>" alt="image">
            <div class="description">
              <h2>
                <%= item.party_name %>
              </h2>
              <h6>Host:
                <%= item.full_name %>
              </h6>
              <h5>Address:
                <%= item.address %>,
                  <%= item.city_name %>,
                    <%= item.state_name %>
              </h5>
              <h3>Price:
                <%= item.price %>
              </h3>
            </div>
          </div>
          <% }); %>
      </div>

      <hr>
    </section>

NAHEEM OLANIYAN
  • 143
  • 2
  • 14
  • You don't only use HTML and node.js isn't a programming language, but a javascript runtime. What kind of packages have you already installed? You are using a template engine. Also, you need javascript on the client side with ajax and some kind of server side app to pull the data from the database and send it to the client. – NoNickAvailable Jul 25 '19 at 04:20
  • @NoNickAvailable I am using express with Node.js. My database is MySql. I am already pulling the data out. I thought I can use only HTML and CSS to do this. Please, can you provide a little guidance on how to this or reference? My current thought is to pull all the data gotten from the database into an array and use loop and if statement to limit the paging results. Please let me know your advice and if you need any of my server-side code. Thanks. – NAHEEM OLANIYAN Jul 25 '19 at 06:16

0 Answers0