RE: [PHP-DB] odd results when running this
Thanks, I did use your code as is, and it works perfectly. Regards, Chip "Bastien Koert" <[EMAIL PROTECTED]> wrote on 01/28/2005 09:56:35 AM: > What you should do then is to compare some value to only write the image > data if that value matchesin my code snippet, since you are writing the > same data, i just loop thru it and increment the image counter to output the > correct image. A better way to manage this might be to put the image name in > the db with all the other data as a separate field...then you just fill in > the image dataand reduce the code to pretty much what i had... > > bastien > > >From: Chip Wiegand <[EMAIL PROTECTED]> > >To: php-db@lists.php.net > >Subject: RE: [PHP-DB] odd results when running this > >Date: Fri, 28 Jan 2005 09:17:35 -0800 > > > >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" <[EMAIL PROTECTED]> 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(" > > title=\"%s\">%s", $row["alt-text"], > > > $row["title-text"], $row["desc-text"]); > > >$x++; > > >} > > > ?> > > > > > > bastien > > > > > > >From: Chip Wiegand <[EMAIL PROTECTED]> > > > >To: "PHP DB" > > > >Subject: [PHP-DB] 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 > > > >== > > > > > > >align="center" > > > >summary="table that contains the body of the page"> > > > > > > > > > > > > > > > >Welcome to Simrad, Inc > > > > > > > >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. > > > > > > > > > > > >Read > > >href="SimradNews/Spring2004/SimradNews-p1.html" target="_new"> > > >class="red">SimradNews - Your > > > >quarterly guide to today's marine electronics (opens in a new > >window) > > >/> > > > > > > > > > > > > > > >/> > > > > > > > > > > >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" > >
RE: [PHP-DB] odd results when running this
What you should do then is to compare some value to only write the image data if that value matchesin my code snippet, since you are writing the same data, i just loop thru it and increment the image counter to output the correct image. A better way to manage this might be to put the image name in the db with all the other data as a separate field...then you just fill in the image dataand reduce the code to pretty much what i had... bastien From: Chip Wiegand <[EMAIL PROTECTED]> To: php-db@lists.php.net Subject: RE: [PHP-DB] odd results when running this Date: Fri, 28 Jan 2005 09:17:35 -0800 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" <[EMAIL PROTECTED]> 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(" title=\"%s\">%s", $row["alt-text"], > $row["title-text"], $row["desc-text"]); >$x++; >} > ?> > > bastien > > >From: Chip Wiegand <[EMAIL PROTECTED]> > >To: "PHP DB" > >Subject: [PHP-DB] 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 > >== > > >align="center" > >summary="table that contains the body of the page"> > > > > > > > >Welcome to Simrad, Inc > > > >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. > > > > > >Read >href="SimradNews/Spring2004/SimradNews-p1.html" target="_new"> >class="red">SimradNews - Your > >quarterly guide to today's marine electronics (opens in a new window) >/> > > > > > > >/> > > > > >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">ANNOUNCING > >THE NEW SIMNET NETWORK > > > > > > > >What's New > > >$sql="select * from hotspots"; > >$result = mysql_query($sql); > >while ( $row = mysql_fetch_array($result)) > >{ > > printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > >printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > >printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > > } > >?> > > > > > > > > >cellpadding=&q
RE: [PHP-DB] odd results when running this
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" <[EMAIL PROTECTED]> 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(" title=\"%s\">%s", $row["alt-text"], > $row["title-text"], $row["desc-text"]); >$x++; >} > ?> > > bastien > > >From: Chip Wiegand <[EMAIL PROTECTED]> > >To: "PHP DB" > >Subject: [PHP-DB] 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 > >== > > >align="center" > >summary="table that contains the body of the page"> > > > > > > > >Welcome to Simrad, Inc > > > >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. > > > > > >Read >href="SimradNews/Spring2004/SimradNews-p1.html" target="_new"> >class="red">SimradNews - Your > >quarterly guide to today's marine electronics (opens in a new window) >/> > > > > > > >/> > > > > >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">ANNOUNCING > >THE NEW SIMNET NETWORK > > > > > > > >What's New > > >$sql="select * from hotspots"; > >$result = mysql_query($sql); > >while ( $row = mysql_fetch_array($result)) > >{ > > printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > >printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > >printf(" >title=\"%s\">%s", $row["alt-text"], > >$row["title-text"], $row["desc-text"]); > > } > >?> > > > > > > > > >cellpadding="10" width="80%"> > > > > > > > > > > >onmouseover="window.status='Some Background information about > >Simrad';return true;" > >title="Some Background information about Simrad" > >class="special-links">Simrad has built its name on > >products which do what they are designed to do, whatever the conditions. > >As part of >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, 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. > > > > > > > > > > > >-- > >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
Re: [PHP-DB] odd results when running this
Chip Wiegand wrote: 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 [snip] $sql="select * from hotspots"; $result = mysql_query($sql); while ( $row = mysql_fetch_array($result)) { printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); } ?> Looking at the page, and the code block - the code likely isn't running three times. You have 3 rows in the database, and in your while() loop, you print out the data for each row 3 times. You'll notice on the sidebar in the webpage you have essentially 9 'blocks' of news - they images for them loop (a b c, a b c, a b c) and the text for them repeats ( d d d , e e e , f f f ). Change your loop to print just once, and have a counter that sets the image to load (and if the counter goes beyond 3 - either have it not display the image, or add more images :), or limit the query to only return the latest three (add "limit 0, 3" to the query) ) Cheers, -- - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] odd results when running this
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 while ( $row = mysql_fetch_array($result)) { printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); $x++; } ?> bastien From: Chip Wiegand <[EMAIL PROTECTED]> To: "PHP DB" Subject: [PHP-DB] 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 == Welcome to Simrad, Inc 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. Read SimradNews - Your quarterly guide to today's marine electronics (opens in a new window) ANNOUNCING THE NEW SIMNET NETWORK What's New %s", $row["alt-text"], $row["title-text"], $row["desc-text"]); printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); printf("%s", $row["alt-text"], $row["title-text"], $row["desc-text"]); } ?> Simrad has built its name on products which do what they are designed to do, whatever the conditions. As part of 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, 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. -- 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