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
-----------------------------------
It seems like you need a
whileloop to iterate through the rows like so:However, you should immediately stop using
mysql_functions as they are being deprecated and vulnerable to SQL injection; and usemysqli_orPDOinstead.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.
For the first row, the output would be: