A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Display 3 records at a time

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1

    Display 3 records at a time

    I'm trying to display the newest 3 news posts and than give the user the option to press a button to display the next 3 and so on
    I've been at this for hours and I'm pretty sure my php is good i think I'm getting confused with the action script on the button so ill post both my php and button code see if anyone else has a fresh view


    $records_displayed = 3;
    if ( !isset($low)){
    $low = 0;
    }
    if (!isset($high) ){
    $high = $records_displayed;
    }
    $conn = db_connect();
    $sql = "SELECT * FROM news_post ORDER BY id DESC";
    $max_results = mysql_query($sql, $conn) or die(mysql_error());
    $count = mysql_num_rows($max_results);
    print "&max_records=";
    print "$count";

    $sql = "SELECT * FROM news_post ORDER BY id DESC LIMIT $low, $high ";
    $result = mysql_query($sql, $conn) or die(mysql_error());

    if (($low < 0) || ($low > $count)){
    print "&left=No More Entries.";
    }
    else { print "&left=";
    }
    print "&news=";
    while ($newArray = mysql_fetch_array($result)) {
    // give a name to the fields
    $id = $newArray['id'];
    $name = $newArray['name'];
    $headline = $newArray['headline'];
    $post = $newArray['post'];
    $date = $newArray['date'];
    print "<P><b><font color=\"#000000\">[$id] $headline <br> <font color=\"#CC6600\">$post <br><font color=\"#000000\">By: $name Posted: $date <br><font color=\"#CC6600\">§§§§§§§§§§§§§§§§ §§§§§§§§§§§§§</P>";
    }


    on (press) {

    low = Number(low)+Number(3);
    high = Number(high)+Number(3);
    loadVariables("http://MYSITE/MYFOLDER/news.php?low="+low+"&R="+random(999) , POST);

    }

    I don't get any errors just nothing happens when i press the button
    and as u can see in the php code i added prints to make sure the data was even spitting out
    Thnx in advance

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    this does not look basically wrong...
    First of all, there is
    $low
    etc. in your php rather than $_REQUEST['low']
    This means you either need to have a very old php version running, or one where the server config still allows globals (some servers do for existing clients, just to not disrupt their scripts)
    Upload a file with
    Code:
    <? php_info(); ?>
    to your server and watch it in the browser. Look for a setting called "register_globals". If that is not the problem, just view the news.php url in browser - any error messages?

    Things that you might want to improve:
    a) there does not seem to be any post data, since all the info is part of the url. Why not use GET?
    b) mysql has
    Code:
    select count(*)
    to get the number of entries.

    Musicman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center