Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / February 2007



Tip: Looking for answers? Try searching our database.

Browsing loaded images

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thahip - 21 Feb 2007 18:25 GMT
Hi,

I am loading images from a mysql database. Lets say I was displaying 8 on a
page, how can I tell how many pages I have and have it update when more images
are added?

Like on sites where they have links like

images 1-12 | 13-25 | 26-38 | 39-51  etc

thanks

Gavin
MotionMaker - 22 Feb 2007 12:06 GMT
Your server script would need to use SQL to get a count on the table holding
the image data each time the user selects a new image in Flash. Then send that
data back. Then Flash would reconfigure the user interface should the count
change. This creates some interesting programming challenges is something like
the user is viewing 39-51 and on the next view the server now reports only 20
images.

The bigger question is about design: "when should the app request the data
that configures the image counts? "Once on app launch, based on a timer
interval, when the user interacts with image selections as mentioned above,
provide the user a refresh interaction.
thahip - 22 Feb 2007 15:01 GMT
Hi,

I have looked at the count sql function, and this looks like it will be
useful, however my coding knowledge is not high.

At present this sort of code is being used to access the database and also the
flash to display it.

<?php
$connect = mysql_connect("localhost", "user", "pass");
mysql_select_db("database_name", $connect);
$result = mysql_query("SELECT Title, Comments, Image FROM titles");
$cant = 0;
while($row=mysql_fetch_array($result)){
    echo
"Title$cant=$row[Title]&Comments$cant=$row[Comments]&Image$cant=$row[Image]&";
    $cant++;
}
echo "cant=$cant";
?>

Actionscript -

//Create LoadVars object and load file
myData = new LoadVars()
myData.load("file_name.php") //php line
myData.ref = this
//Fetch data
myData.onLoad = function(succes){
    if(succes){
        for(var i=0; i<this.cant; i++){
            this.ref["Title_txt"+i].htmlText = "[B]"+this["Title"+i]+"[/B]"
            this.ref["Comments_txt"+i].text = this["Comments"+i]
            this.ref["holder_mc"+i].loadMovie(this["Image"+i])
        }
    } else trace("Error loading data");
}

Any ideas on how to approach the problem, and any useful links would be great

thanks

Gavin
MotionMaker - 22 Feb 2007 15:39 GMT
Send the total row count back and on the AS side you need to do math to
determine what number of views you have. If you show 12 images, the divide the
total row count by 12 and if you have a remainder add 1 to get the total views.
In this case view 1 is always 1-12 and view 2 is always 13-25.

PHP

$numrows = mysql_num_rows($result);

echo "cant=$cant&count=$numrows";
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.