FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » values not changing
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: values not changing [message #181566 is a reply to message #181557] Wed, 22 May 2013 00:32 Go to previous message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma:
Junior Member
richard wrote:

> www.mroldies.net
>
> I am attempting to change the play list given the year selected.
> However, regardless of which year is chosen, the code selects only the
> originally loaded playlist.
>
> What am I missing?
>
>
>
> <?php
>
> $year=$_GET["year"];
> if (empty($year)) {$year=1900;}
> $year=(int)$year;
>
> echo $year;
>
> if ($year=1900)
> {echo '<iframe width="800" height="800" src="test2.php"
> frameborder="0"></iframe>';}
>
> if ($year>1900)
> {
> /* connect to the db */
> $con = mysql_connect('localhost','user','pass');
>
>
> if (!$con){die("can not connect: " . mysql_error());}
>
> mysql_select_db('richbull_top100',$con);
>
> while ($number<=10):
> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }

<SNIP> rest of script

In addition to the problems mentioned by others:

you haven't initialised $number for use in the while loop;

the above while loop causes a number of queries to be run, instead you could
use BETWEEN in the query to select matching records for values of id BETWEEN
n and 10;

you have no graceful handling of an error when running a query - the script
just dies

--
Cheers
David Robley

Useless Invention: Soap Dissolver.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: insert PDF table in database
Next Topic: Got it working finally
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 08:41:08 GMT 2024

Total time taken to generate the page: 0.03639 seconds