PHP Mysql Outputting Records Repeatedly.

PHP Mysql Outputting Records Repeatedly.

am 16.01.2008 10:34:33 von cgkh.webservices

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=3Dsel_hote l_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:

"

require_once('xxxxxx.php');

$prop_sel_1 =3D "SELECT
CASAS.area_id,CASAS.casa_id,CASAS.casa_nom,CASAS.quartos,CAS AS.pessoas,CASAS=
..preco_natal,CASAS.preco_jan,CASAS.preco_fev,CASAS.preco_ma r,CASAS.preco_abr=
,CASAS.preco_mai,CASAS.
preco_jun,CASAS.preco_jul,CASAS.preco_ago,CASAS.preco_set,CA SAS.preco_out,CA=
SAS.preco_nov,CASAS.preco_dez,CASAS.preco_pascoa,CASAS.casa_ text_pt,CASAS.fo=
rm_url_pt,CASAS.cas_img_ref_1,CASAS.active,CASAS.hotel,TOWNS .area_id,TOWNS.n=
ame,TOWNS.text_pt,TOWNS.text_2_pt,TOWNS.img_ref_2
FROM CASAS,TOWNS WHERE CASAS.hotel=3D'Yes' LIMIT 0, 8";
$prop_sel_2 =3D mysql_query($prop_sel_1) or die(mysql_error());
while($prop_sel_3 =3D mysql_fetch_array($prop_sel_2,MYSQL_ASSOC ))
{

Print "";
Print "3D\" ter
\" src=3D\"images/prop_baa.jpg\" vspace=3D\"2\">";
Print "";
Print "";
Print "";
Print "";
Print "

=3D
\"99%\" align=3D\"center\">";
Print "";
Print "";
$foto=3D$prop_sel_3['casa_id'];
$fotos=3D"index.php?content=3Dsel_prop_foto&casa_id=3D$foto" ;
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "
" .
$prop_sel_3['casa_nom'] . "

\"center\" NOSHADE>
\"images/".$prop_sel_3['cas_img_ref_1']."\" hspace=3D\"3\" vspace=3D
\"4\">
";
Print " =3D
\"95%\" align=3D\"center\">";
Print "";
Print "";
Print "";
Print "";
Print "
Pessoas " .
$prop_sel_3['pessoas'] . "
Quartos " .
$prop_sel_3['quartos'] . "
";
Print "
";
Print " =3D
\"95%\" align=3D\"center\">";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "";
Print "
\"price_head\">Preços por semana:
Janeiro

€" . $prop_sel_3['preco_jan'] . "
Fevreiro
€" .
$prop_sel_3['preco_fev'] . "
Mar=E7o
=

€" . $prop_sel_3['preco_mar'] . "
Abril
€" .
$prop_sel_3['preco_abr'] . "
Maio

€" . $prop_sel_3['preco_mai'] . "
Junho
€" .
$prop_sel_3['preco_jun'] . "
Pascoa.

€" . $prop_sel_3['preco_pascoa'] . "
Julho
€" .
$prop_sel_3['preco_jul'] . "
Agosto

€" . $prop_sel_3['preco_ago'] . "
Setembro
€" .
$prop_sel_3['preco_set'] . "
Octobro

€" . $prop_sel_3['preco_out'] . "
Novembro
€" .
$prop_sel_3['preco_nov'] . "
Dezembro

€" . $prop_sel_3['preco_dez'] . "
Natal
€" .
$prop_sel_3['preco_natal'] . "
";
Print "
";
Print "";
Print "";

}
mysql_free_result($result);

?>"

Where I am going wrong??????????

Many thanks for any help for this dumbo!

Re: PHP Mysql Outputting Records Repeatedly.

am 16.01.2008 13:00:15 von Jerry Stuckle

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:
>
> "
> >
> require_once('xxxxxx.php');
>
> $prop_sel_1 = "SELECT
> CASAS.area_id,CASAS.casa_id,CASAS.casa_nom,CASAS.quartos,CAS AS.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,CA SAS.preco_out,CASAS.preco_nov,CASAS.preco_dez,CASAS.preco_pa scoa,CASAS.casa_text_pt,CASAS.form_url_pt,CASAS.cas_img_ref_ 1,CASAS.active,CASAS.hotel,TOWNS.area_id,TOWNS.name,TOWNS.te xt_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 "";
> Print "\" > \" src=\"images/prop_baa.jpg\" vspace=\"2\">";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "

> \"99%\" align=\"center\">";
> Print "";
> Print "";
> $foto=$prop_sel_3['casa_id'];
> $fotos="index.php?content=sel_prop_foto&casa_id=$foto";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "
" .
> $prop_sel_3['casa_nom'] . "

> \"center\" NOSHADE>
> \"images/".$prop_sel_3['cas_img_ref_1']."\" hspace=\"3\" vspace=
> \"4\">
";
> Print " > \"95%\" align=\"center\">";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "
Pessoas " .
> $prop_sel_3['pessoas'] . "
Quartos " .
> $prop_sel_3['quartos'] . "
";
> Print "
";
> Print " > \"95%\" align=\"center\">";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "";
> Print "
> \"price_head\">Preços por semana:
Janeiro
>
€" . $prop_sel_3['preco_jan'] . "
Fevreiro
€" .
> $prop_sel_3['preco_fev'] . "
Março

> €" . $prop_sel_3['preco_mar'] . "
Abril
€" .
> $prop_sel_3['preco_abr'] . "
Maio

> €" . $prop_sel_3['preco_mai'] . "
Junho
€" .
> $prop_sel_3['preco_jun'] . "
Pascoa.
>
€" . $prop_sel_3['preco_pascoa'] . "
Julho
€" .
> $prop_sel_3['preco_jul'] . "
Agosto
>
€" . $prop_sel_3['preco_ago'] . "
Setembro
€" .
> $prop_sel_3['preco_set'] . "
Octobro
>
€" . $prop_sel_3['preco_out'] . "
Novembro
€" .
> $prop_sel_3['preco_nov'] . "
Dezembro
>
€" . $prop_sel_3['preco_dez'] . "
Natal
€" .
> $prop_sel_3['preco_natal'] . "
";
> Print "
";
> Print "";
> Print "";
>
> }
> 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
==================

Re: PHP Mysql Outputting Records Repeatedly.

am 17.01.2008 12:17:36 von Ramon Rabaso

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.
>
> >
> require_once('xxxxxx.php');
>
> $prop_sel_1 = "SELECT
> CASAS.area_id,CASAS.casa_id,CASAS.casa_nom,CASAS.quartos,CAS AS.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,CA SAS.preco_out,CASAS.preco_nov,CASAS.preco_dez,CASAS.preco_pa scoa,CASAS.casa_text_pt,CASAS.form_url_pt,CASAS.cas_img_ref_ 1,CASAS.active,CASAS.hotel,TOWNS.area_id,TOWNS.name,TOWNS.te xt_pt,TOWNS.text_2_pt,TOWNS.img_ref_2
> FROM CASAS,TOWNS WHERE CASAS.hotel='Yes' LIMIT 0, 8";

Hi,

PhP and MySQL/SQL are not my tongue languages but I think I can help you
on this.

Try changing your WHERE clausule in your query to:
....WHERE CASAS.hotel='Yes' and CASAS.area_id = TOWNS.area_id LIMIT 0,8";

Of course I didn't test it, but I bet it helps.

Good luck!

Ramon Rabaso
http://www.realtimequery.com - Live Help for Websites.