Immortal55 Posted December 6, 2006 Share Posted December 6, 2006 Alright, I am doing a little dynamic loading in flash, and I am trying to load the variables from a PHP script. I make an array based on the entries in the table, and then they are passed on to flash....The only thing is is that my script grabs the same story multiple times.....and sometimes in a nonsense order....Here is the script:[code]mysql_connect('localhost','admin','iffy') or die ('Could not connect to database');mysql_select_db('whitedevil') or die ('Yeah, your database was found, but not the tables!'); $result = mysql_query('SELECT * FROM news') or die ('no query');if ($result) { while ($tablefield = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $tablefield['id']; $title = $tablefield['title']; $author = $tablefield['author']; $date = $tablefield['date']; $text = $tablefield['story']; $numReturn = count($tablefield); $i = 0; print "&"; while ($i < $numReturn) { $Name = $title; $TextData = $text; $Author = $author; $TheDate = $date; print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=TheDate&"; $i++; }print "&NumItems=$numReturn&Go=Yes&"; }} else { print('Sorry, no work.'); }[/code]now what would be doing that?? Thank you in advance! Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted December 6, 2006 Author Share Posted December 6, 2006 I altered the code a little bit.....but now it only shows the most recently added entry in the database, but only once.here it is:[code]if ($result) { while ($tablefield = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $tablefield['id']; $title = $tablefield['title']; $author = $tablefield['author']; $thedate = $tablefield['date']; $text = $tablefield['story'];} $numReturn = count($tablefield); $i = 0; while ($i < $numReturn) { $Name = $title; $TextData = $text; $Author = $author; $TheDate = $thedate; print "&"; print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=$TheDate"; $i++; }print "&NumItems=$numReturn&Go=Yes&"; }[/code]Help appreciated! Thank you! Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted December 6, 2006 Author Share Posted December 6, 2006 According to the last post (which is still the current state of my script) It shows only one set of information from the table, the most recently added one to say. What could the problem be? This is really tough!Thanks in advance again. Quote Link to comment Share on other sites More sharing options...
btherl Posted December 6, 2006 Share Posted December 6, 2006 Immortal, I think your problems will go away when you fix your indentation. Make sure every "while", every "if" and every "for" has a closing brace underneath it in the same column.In your latest code, the closing brace for your while loop is in the wrong column. This makes it unclear that the while loop finishes too early. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.