You are here: Re: PHP Mysql Outputting Records Repeatedly. « All PHP « IT news, forums, messages
Re: PHP Mysql Outputting Records Repeatedly.

Posted by Jerry Stuckle on 09/29/15 12:00

cgkh.webservices wrote:
> Would be grateful for any help.
>
> I have not messed with php/mysql in a while and have come up with a
> problem I have run up against before but cannot remember the solution.
>
> See the following page:
>
> http://www.paraisolpraia.com/index_pt.php?content=sel_hotel_pt
>
> I am calling two records from a mysql database with a php script but
> as you can see the records are looping and printing repeatedly.
>
> The code I am using is as follows:
>
> "
> <?php
>
> require_once('xxxxxx.php');
>
> $prop_sel_1 = "SELECT
> CASAS.area_id,CASAS.casa_id,CASAS.casa_nom,CASAS.quartos,CASAS.pessoas,CASAS.preco_natal,CASAS.preco_jan,CASAS.preco_fev,CASAS.preco_mar,CASAS.preco_abr,CASAS.preco_mai,CASAS.
> preco_jun,CASAS.preco_jul,CASAS.preco_ago,CASAS.preco_set,CASAS.preco_out,CASAS.preco_nov,CASAS.preco_dez,CASAS.preco_pascoa,CASAS.casa_text_pt,CASAS.form_url_pt,CASAS.cas_img_ref_1,CASAS.active,CASAS.hotel,TOWNS.area_id,TOWNS.name,TOWNS.text_pt,TOWNS.text_2_pt,TOWNS.img_ref_2
> FROM CASAS,TOWNS WHERE CASAS.hotel='Yes' LIMIT 0, 8";
> $prop_sel_2 = mysql_query($prop_sel_1) or die(mysql_error());
> while($prop_sel_3 = mysql_fetch_array($prop_sel_2,MYSQL_ASSOC ))
> {
>
> Print "<tr>";
> Print "<td colspan=\"8\" align=\"center\"><img alt=\" \" align=\"center
> \" src=\"images/prop_baa.jpg\" vspace=\"2\"></td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td></td>";
> Print "<td colspan=\"6\">";
> Print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=
> \"99%\" align=\"center\">";
> Print "<tr>";
> Print "<td><div align=\"left\" class=\"title_index\">" .
> $prop_sel_3['casa_nom'] . "</div></td>";
> $foto=$prop_sel_3['casa_id'];
> $fotos="index.php?content=sel_prop_foto&casa_id=$foto";
> Print "<td><div align=\"right\" class=\"top_menu\"><a href=\"$fotos\"
> target=\"_blank\" class=\"top_menu\">Ver fotografias, clique aqui!</
> div></td>";
> Print "</tr>";
> Print "<tr height=\"20\">";
> Print "<td colspan=\"8\" valign=\"middle\"><hr size=\"1\" align=
> \"center\" NOSHADE></td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td valign=\"middle\"><div align=\"justify\" class=\"casa_text
> \"><a href=" . $prop_sel_3['form_url_pt'] ." class=\"casa_text\">".
> $prop_sel_3['casa_text_pt'] . "</a></div></td>";
> Print "<td rowspan=\"2\" align=\"right\" valign=\"top\"><img src=
> \"images/".$prop_sel_3['cas_img_ref_1']."\" hspace=\"3\" vspace=
> \"4\"></td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td>";
> Print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=
> \"95%\" align=\"center\">";
> Print "<tr>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\">Pessoas " .
> $prop_sel_3['pessoas'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\">Quartos " .
> $prop_sel_3['quartos'] . "</div></td>";
> Print "</tr>";
> Print "</table>";
> Print "</td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td colspan=\"2\">";
> Print "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=
> \"95%\" align=\"center\">";
> Print "<tr height=\"20\">";
> Print "<td colspan=\"7\" valign=\"top\"><div align=\"left\" class=
> \"price_head\"><strong>Pre&ccedil;os por semana:</strong></div></td>";
> Print "</td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Janeiro
> <br> &#128;" . $prop_sel_3['preco_jan'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Fevreiro <br> &#128;" .
> $prop_sel_3['preco_fev'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Março <br>
> &#128;" . $prop_sel_3['preco_mar'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Abril <br> &#128;" .
> $prop_sel_3['preco_abr'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Maio <br>
> &#128;" . $prop_sel_3['preco_mai'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Junho <br> &#128;" .
> $prop_sel_3['preco_jun'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Pascoa.
> <br> &#128;" . $prop_sel_3['preco_pascoa'] . "</div></td>";
> Print "</tr>";
> Print "<tr>";
> Print "<td><div class=\"price_yellow\"> Julho <br> &#128;" .
> $prop_sel_3['preco_jul'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Agosto
> <br> &#128;" . $prop_sel_3['preco_ago'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Setembro <br> &#128;" .
> $prop_sel_3['preco_set'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Octobro
> <br> &#128;" . $prop_sel_3['preco_out'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Novembro <br> &#128;" .
> $prop_sel_3['preco_nov'] . "</div></td>";
> Print "<td bgcolor=\"#ffa200\"><div class=\"price_yellow\"> Dezembro
> <br> &#128;" . $prop_sel_3['preco_dez'] . "</div></td>";
> Print "<td><div class=\"price_yellow\"> Natal <br> &#128;" .
> $prop_sel_3['preco_natal'] . "</div></td>";
> Print "</tr>";
> Print "</table>";
> Print "</td>";
> Print "</tr>";
> Print "</table>";
> Print "</td>";
> Print "</tr>";
>
> }
> mysql_free_result($result);
>
> ?>"
>
> Where I am going wrong??????????
>
> Many thanks for any help for this dumbo!
>
>
>
>

Fix you SQL query.

Try running your query from a MySQL command line prompt (or in
PHPMyAdmin) and see what you get.

If you still can't find it, try a MySQL newsgroup such as
comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация