SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    static and dynamic array

    i wanna add more interactive service to my user by placing dynamic message board, in the fact it just scrolling mesage using javascript.I use php and mysql to handle the data dynamically, so every user who has fill the form will see the result immediatelly,but i get the problem to make the array like:

    messages[0]="id1,name1,messages1 "
    messages[1]="id2,name2,messages2 "
    etc

    i can't make the part "messages[]" keep static from 0 till 25 and "id1,name1,messages1 from database" keep growing from use entry(store in mysql database).
    here's the code:

    <?
    include("dbik.php");
    $conn = mysql_connect(localhost,$user,$pass);
    $select =@mysql_select_db("$db")or die ("unable to select db");
    $result=mysql_query("select * "."from pesan ". "order by id limit 20");
    while ($data=mysql_fetch_array($result))
    {

    $pesan=ucfirst($data[pesan]);

    ?>

    messages[<? echo$data[id];?>]="Pesan No:#<? echo$data[id];?><br>Buat<? echo ucfirst($data[untuk]);?>)<br><br><? echo $pesan;?></font><br><br>Dari :&nbsp;<a href='mailto? echo$data[email];?>'><? echo ucfirst($data[nama]);?><hr width=95% color=brown><br>"
    <?

    }
    ?>

    any idea how to solve this???
    any comments are appreciate, thank you.
    www.djklik.com
    daily indonesian news on your computer

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may not have had any replies because it is not clear what your problem is

    Arrays in PHP are dynamic. In fact they are amazing - the best/simplest implimentation of a container structure I have come accross in a programming language. I just discovered that you can use arrays as queues with functions array_push() and array_pop() the other day. http://au.php.net/manual/en/function.array.php

    I don't quite follow how messages relates to pesan and what the problem is. I assume that you will want to have a table in your databse named messages which has a reference to the person in table pesan?


Bookmarks

Posting Permissions

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