RE: odd results when running this

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the tips. 
I find this confusing - I have 3 statements pulling 3 differant images, so 
I don't understand why the script would run 3 times if there is not loop 
telling it to do so. Shouldn't it just load each image and then stop? 
Doesn't the while loop stop when it hits the last row?
--
Chip

"Bastien Koert" <bastien_k@xxxxxxxxxxx> wrote on 01/28/2005 08:37:58 AM:

> it runs three times because there are three rows of data and you are 
setting 
> the same thing for each set of data.
> 
> try this
> 
> <?
> $sql="select * from hotspots";
> $result = mysql_query($sql);
> $x = 1;
> 
> while ( $row = mysql_fetch_array($result))
>    {
>          printf("<p><img src=\"hotspots/latest$x.gif\" alt=\"%s\"
> title=\"%s\"></p><p class=\"footnote\">%s</p>", $row["alt-text"],
> $row["title-text"], $row["desc-text"]);
>    $x++;
>    }
> ?>
> 
> bastien
> 
> >From: Chip Wiegand <chip.wiegand@xxxxxxxxxx>
> >To: "PHP DB" <php-db@xxxxxxxxxxxxx>
> >Subject:  odd results when running this
> >Date: Fri, 28 Jan 2005 07:41:30 -0800
> >
> >Okay, so I have got the php bits working in this web page but it is
> >running 3 times every time the page loads, and I see no reason why (I 
have
> >opened this page in two differant browsers). The code for the entire 
page
> >is pasted below, it includes some calls to include files which are not
> >included in this message of course (and this file is itself included in
> >another file), the page can be seen at this address:
> >http://www.simradusa.com/index-test.php
> >If anyone can see any reason for the script to run 3 times please let 
me
> >know.
> >Thanks,
> >Chip
> >======================================================================
> ><table width="100%" border="0" cellpadding="5" cellspacing="0"
> >align="center"
> >summary="table that contains the body of the page">
> ><tr>
> ><td>
> ><div align="top">
> ><p class="welcome">Welcome to Simrad, Inc</p>
> ><p class="paratext">
> >Simrad is one of the world's largest manufacturers of marine 
electronics
> >for the yachting,
> >fishery and commercial marine markets, offering sales and service
> >worldwide. A complete
> >range of products from Simrad is available for many different types of
> >marine activity,
> >including auto steering, navigation, hydro acoustic and communication
> >equipment. Ranging
> >from pleasure boating, through fishing and into commercial craft. 
Please
> >select the type
> >of activity that you are interested in using the links on the left.
> ></p>
> ><br /><br /><br />
> ><p class="paratext">Read <a
> >href="SimradNews/Spring2004/SimradNews-p1.html" target="_new"><span
> >class="red">Simrad</span><span class="blue">News</span></a> - Your
> >quarterly guide to today's marine electronics (opens in a new 
window)<br
> >/>
> ><!-- Or download the .pdf version <a

> >href="SimradNews/Spring2004/SimradNews.php">here</a> (765Kbytes) 
--></p>
> ><br />
> ><p class="c2"><img src="images/sim-net-icon.gif" alt="ANNOUNCING THE 
NEW
> >SIMNET NETWORK" border="0" title="SAWDUST helm - all Simrad products"
> >/></p>
> ><p>
> ><a href="#"
> >onclick="window.open('simnet.html','simnet','toolbar=no,width=450,
> height=500,left=0,top=0,screenX=0,screenY=0,status=no,
> scrollbars=yes,resize=yes');return
> >false"
> >  onmouseover="window.status='ANNOUNCING THE NEW SIMNET NETWORK';return
> >true;"
> >onmouseout="window.status='ANNOUNCING THE NEW SIMNET NETWORK'; return
> >true;"
> >  title="Read more about the SimNet" 
class="special-links"><em>ANNOUNCING
> >THE NEW SIMNET NETWORK</p>
> ></div>
> ></td>
> ><td><br />
> ><p class="title">What's New</p>
> ><?
> >$sql="select * from hotspots";
> >$result = mysql_query($sql);
> >while ( $row = mysql_fetch_array($result))
> >    {
> >          printf("<p><img src=\"hotspots/latest1.gif\" alt=\"%s\"
> >title=\"%s\"></p><p class=\"footnote\">%s</p>", $row["alt-text"],
> >$row["title-text"], $row["desc-text"]);
> >    printf("<p><img src=\"hotspots/latest2.gif\" alt=\"%s\"
> >title=\"%s\"></p><p class=\"footnote\">%s</p>", $row["alt-text"],
> >$row["title-text"], $row["desc-text"]);
> >    printf("<p><img src=\"hotspots/latest3.gif\" alt=\"%s\"
> >title=\"%s\"></p><p class=\"footnote\">%s</p>", $row["alt-text"],
> >$row["title-text"], $row["desc-text"]);
> >          }
> >?>
> ></td>
> ></tr>
> ></table>
> ><table summary="company blurb" align="center" border="0" 
cellspacing="0"
> >cellpadding="10" width="80%">
> ><tr>
> ><td colspan="2">
> ><div class="co-blurb">
> ><hr width="75%" />
> ><p class="paratext"><a href="contact/simradbackground.php"
> >onmouseover="window.status='Some Background information about
> >Simrad';return true;"
> >title="Some Background information about Simrad"
> >class="special-links">Simrad</a> has built its name on
> >products which do what they are designed to do, whatever the 
conditions.
> >As part of <a
> >href="http://www.kongsberg.com/";
> >onmouseover="window.status='The Kongsberg Maritime Corporate Home
> >Page';return true;"
> >title="Our corporate parent company home page" target="_blank"
> >class="special-links">Kongsberg Maritime</a>, the largest
> >manufacturer of marine electronics in the world, Simrad manufactures
> >products which are
> >developed and built on the same principles as the company's 
sophisticated
> >electronics
> >for the demanding commercial shipping and fisheries market.</p>
> ></div>
> ></td>
> ></tr>
> ></table>
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux