|
Posted by solpraiaferias@gmail.com on 12/12/06 12:56
Thanks so much!
Still learning.
Have taken onboard you comments and am going back to the drawinf board.
Many Thanks
J.O. Aho wrote:
> solpraiaferias@gmail.com wrote:
> > Sorry to bother folks but have been going mad the past 48 hours.
> >
> > Have done something wrong but cannot see it!
> >
> > I have php code retrieving results from mysql database and displaying
> > to web page on my site:
> >
> > see development page at:
> >
> > http://www.solpraiaferias.com/surfalgarve/test_surf.php
> >
> > You will see that it is looping and displaying the results several
> > times.
>
> > $sql_surf = "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_en,CASAS.form_url_en,CASAS.cas_img_ref_1,CASAS.surf,CASAS.active,TOWNS.area_id,TOWNS.name,TOWNS.text_en,TOWNS.text_2_en,TOWNS.img_ref_2
> > FROM CASAS,TOWNS WHERE CASAS.surf='Yes' AND CASAS.active='Yes' LIMIT 0,
> > 30 ";
> >
> > $surf_result = mysql_query($sql_surf) or die(mysql_error());
> >
> > Print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
> > width=\"95%\" align=\"center\">";
> >
> > while($surf_row_1 = mysql_fetch_array( $surf_result,MYSQL_ASSOC ))
> > {
> > Print "<tr>";
> <cut ... cut>
> > Print "</tr>";
> > mysql_close($dbh);
> > }
> > Print "</table>";
>
> move the mysql_close() to outside the while loop
>
> Have you looked how your table looks like? I mean use another method to access
> the data, for it seems like you have more than one entry of your data, that
> you have entered everything 4 times, I would suggest you have a better way to
> determine dubblicates when you insert data.
>
> I think your outputting is a bit difficult to see, you could use
>
>
> echo <<<EOF
> <tr>
> <td colspan="8">
> <img alt=" " src="images/prop_baa.jpg" vspace="5">
> </td>
> </tr>
> <tr>
> <td>
> </td>
> <td colspan="6">
> <table border="0" cellpadding="0" cellspacing="0" width="95%" align="center">
> <tr>
> <td>
> <div align="left" class="textgreen2menu">
> {$surf_row_1['casa_nom']}
> </div>
> </td>
> (and so on ... )
> EOF;
>
> This makes it a lot easier to see where everything belongs, and when you
> inject a variable into it, just use {} around it, then you don't have to break
> the output. As you see you don't need to escape double/single quotes, whih
> makes it even easier to follow and less risk that there comes an error for you
> missed to escape one.
>
>
> //Aho
Navigation:
[Reply to this message]
|