Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 01:55
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  increment with php
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: increment with php  (Read 760 times)
gareth
Server what's that
*
Posts: 21



View Profile Email
« on: 02/13/04, 15:15 »

Hy, I have a php script "topic.php" that selects row's id and a function that displays the information of the coresponding row:
Code:

$v_query = "SELECT id FROM mytable WHERE category ='v' ORDER BY RAND()";
$rowcase = mysql_query($v_query);
while ($id = mysql_fetch_row($rowcase){
       function($id);
          if($_GET['queue']==1){
         $id++;    
                         }        
}


I have a button "next" in my flash file which sends "queue=1" when pressed, so that it increments $id and displays another row. this is the actionscript:
Code:

on(press){
   var queue=1;
   getURL ("topic.php", "", "GET");
   }
on(release){
   var queue=0;   
}

It's not working and I have no idea how to fix this. I've been looking at a few tutorials but I haven't found one yet that was appropriate to my problem. I really need some help on this.
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #1 on: 02/14/04, 01:53 »

 Hi,

whenever you clicjk the button in the movie, the entire php file is run, and the "queue" variable is set to one.
On the php side, the $id returned from mysql_fetch_row is an array - you can hardly increment that

The common way to solve this problem involves a mysql LIMIIT  bit, so on the first  call the movie would ask for the first entry, and on later calls send a number describing the requested row. Unfortunately you cannot use that with a random query, so you would either have to replace the random thing by something not so random, or actually do a random query once and temporarily save the result for the particular user

Musicman
Logged
gareth
Server what's that
*
Posts: 21



View Profile Email
« Reply #2 on: 02/14/04, 02:16 »

okay I see it's a bit more complex than I though. thanks for the help musicman.
Logged
gareth
Server what's that
*
Posts: 21



View Profile Email
« Reply #3 on: 02/17/04, 22:39 »

ok so i fixed a few things,everything is working but for the incrementation part, here's that part of topic.php that fisrt get an array of id and then display the row information thanks to "function" which is working properly :
Code:

$x = 0;
$v_query = "SELECT id FROM mytable WHERE category ='v' ORDER BY RAND()";
$rowcase = mysql_query($v_query);
while($id = mysql_fetch_row($rowcase)){                
function($id[$x]);
if($_POST['queue']==1)
   $x++;
}


here's the code for the next button in my flash file, myVars is a LoadVars object in the mainframe that display the variables from the php.As mentioned previously by Musicman,  I changed the getURL by a LoadVars.sendAndLoad() method so that the whole script is not run everytime the button is pressed:
Code:

on(press){
   myData = new LoadVars();
   myData.queue = 1;
   myData.sendAndLoad("topic.php", myVars);

   }
on(release){
   myData.queue=0;
   
}

So far I am able to get the first row from Mysql with the coresponding id, but I don't get any responses when I clicked on the next button. I would like to get the next row from my Mysql.
My problem is really in how to get the next row to be displayed.
I can't get it to work, maybe there's a better way, any suggestion would be gladly taken.
Logged
gareth
Server what's that
*
Posts: 21



View Profile Email
« Reply #4 on: 02/19/04, 14:47 »

Help, please anybody, anything, just throw me a bone here...
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #5 on: 02/19/04, 16:50 »

Hi,

well, I am repeating myself Sad
the proper way to do this is not that queue variable, but a variable inside flash that is incremented. The guestbook tutorial uses a similar technique: when the movie is loaded, some variable (NumLow) is set to 0
The next nd previous buttons change that varible and send it to the server

In your case, that particular variable would be used in a mysql LIMIT clause

Musicman
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything