Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9012415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:59:23+00:00 2026-06-16T02:59:23+00:00

This is the function im using to show results in the index.php with the

  • 0

This is the function im using to show results in the index.php with the style.css correctly done with the li´s and the div´s all that i just want to show in every li the price or the service i want. EXAMPLE: ($_GET_ROW['ID'] = '1', $_GET_ROW['ID'] = '2').

function products() { $get = mysql_query('SELECT id, servico, preco FROM loja');

 if (mysql_num_rows($get)==0) {
    echo "Não existem produtos a serem mostrados!";
} else {
    while ($get_row = mysql_fetch_assoc($get)) {
    echo '<li class="l1 i1 column1">';
    echo '<h2>'.**$get_row["servico"]**. '</h2>';
    echo '<div class="basket"><a href="cart.php?adicionar=' .**$get_row['id']='1'**.'">Adicionar</a></p></div>';
    echo '<div class="preco"><em>Preco:</em><strong>'.number_format($get_row['preco'], 2).'</strong><span>EUR</span>';      
    echo '</div>';
    echo '<li class="l2 i0 column0">';
    echo '<h2>'**.$get_row["servico"].**'</h2>';
    echo '<div class="basket"><a href="cart.php?adicionar=' **.$get_row['id']='2'.**'">Adicionar</a></p></div>';
    echo '<div class="preco"><em>Preco:</em><strong>'.number_format($get_row['preco'], 2).'</strong><span>EUR</span>';      
    echo '</div>';

My database:

-----------------------------------
id servico preco 
-----------------------------------
1 Servico Normal 29.5
-----------------------------------
2 Servico Rapido 32.5
-----------------------------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:59:25+00:00Added an answer on June 16, 2026 at 2:59 am

    It seems like you need a while loop to iterate through the rows like so:

    if (mysql_num_rows($get)==0) {
        echo "Não existem produtos a serem mostrados!";
    } else {
        while($get_row = mysql_fetch_assoc($get)) {
        **echo '<li class="l1 i1 column1">';
        echo '<h2>'.$get_row["servico_normal"].'</h2>';
        echo '<div class="basket"><a href="cart.php?adicionar=' .$get_row['id'].'">Adicionar</a></p></div>';
        echo '<div class="preco"><em>Preco:</em <strong>'.number_format($get_row['preco'], 2).'</strong><span>EUR</span>';      
        echo '</div>';**
        }
    }
    

    However, you should immediately stop using mysql_ functions as they are being deprecated and vulnerable to SQL injection; and use mysqli_ or PDO instead.

    Update 1

    mysql_ functions are officially deprecated.

    The principle of my initial answer still remains. You have two rows in your database and you want to iterate through them.

    while ($get_row = mysql_fetch_assoc($get)) {
        $liClass = 'l' . $get_row[id];
    
        echo '<li class="' . $liClass . ' i1 column1">';
        echo '<h2>' . $get_row[servico] . '</h2>';
        echo '<div class="basket"><p><a href="cart.php?adicionar=' . $get_row['id'] . '">Adicionar</a></p></div>';
        echo '<div class="preco"><em>Preco:</em><strong>' . number_format($get_row['preco'], 2) . '</strong><span>EUR</span>';      
        echo '</div>';
    }
    

    For the first row, the output would be:

    <li class="l1 i1 column1">
    <h2>Servico Normal</h2>
    <div class="basket"><p><a href="cart.php?adicionar=1">Adicionar</a></p></div>
    <div class="preco"><em>Preco:</em><strong>29.50</strong><span>EUR</span></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
I am using this function (that I found on this forum) to calculate the
Hi am using this function that works by a single ID ( 52000121 )
I am using this function to get the featured images: <a href=# rel=prettyPhoto> <?php
I have a criteria query that I am using to show pages of results.
I'm using this code: <script> $(document).ready(function () { $.getJSON(http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?, function(data) { $(.show_tweet).html(data[0].text); }); });
I am using this function try to make a request to the server. I
I am using this function to list items from table helps depending on parameters:
I am using this function to redirect to a random post. I am trying
I am using this function but it is not working. I'm using StoryBoard and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.