#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Ampang, Selangor, Malaysia
    Posts
    6
    Rep Power
    0
    I'm using MySql for the dbase and the record
    has been arranged in this way..
    --------------------------------------------
    ARIES (March 21-April 19): You're on the receiving end of power today, perhaps even of punishment. You may undergo a change in thinking about the use and misuse of power and the effects it has on those on the wrong end of it.

    TAURUS (April 20-May 20): Mature friends help you stabilize your life. They can help you with good advice or by putting in a good word. Let your contacts carry word of your responsibility and reliability. The rest is up to you.

    --------------------------------------------

    Say that, I want it to be displayed in this way
    ------
    ARIES (a link to the record)
    TAURUS (a link to the record)
    -----
    and when user click ARIES it will link to the record itself...
    I have use explode and successfully split the star but I've no idea on how to make the result to be displayed as below...

    ---------------------------------------------
    ARIES
    You're on the receiving end of power today, perhaps even of punishment. You may undergo a change in thinking about the use and misuse of power and the effects it has on those on the wrong end of it.
    ---------------------------------------------

    This is my coding that i've made.. please change or add if you think that it's doesnt make sense...
    ------------Start Codes----------------
    $result = myquery("SELECT * FROM ".$program['table_name']." WHERE TO_DAYS(docdate) <
    = TO_DAYS(NOW()) ORDER BY docdate DESC LIMIT 0,1;", 'dbase_name');
    $row = mysql_fetch_array($result);

    if (isset($row)) {
    $result2 = myquery("SELECT * FROM ".$program['table_name']." WHERE id=".$row['id'].";", 'dbase_name');
    }

    while ($article = mysql_fetch_array($result2)) {
    clean_slashes($article);
    $line = split("[nr]", $article['body']);
    while (list($key, $val) = each($line)) {
    $val = trim($val);
    if (!empty($val)) {
    $regs = explode(' ',$val);
    $star = $regs[0];
    echo "<tr><td><a href="$PHP_SELF?star=$star&article=".$article['id']."">$star</a></td></tr>n";
    }
    }
    ---------------End Codes--------------------
    Please if someone could help me .Thank you.



    ------------------
    ThAnks GuYs !
    -- AiShAh --
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    aishah,
    i don't know why you are using two sql statments here...


    ("SELECT * FROM ".$program['table_name']." WHERE TO_DAYS(docdate) <
    = TO_DAYS(NOW()) ORDER BY docdate DESC LIMIT 0,1;",

    here why you want to use limit..So you will get only one record...

    i'm writing the programming flow here ..just edit this and give a try..


    <?

    $con=mysql_connect('localhost','username','password');
    //connection string

    mysql_select_db("databasename",$con);
    //Select your database..


    if (!isset($star)){
    // if user has not clicked on stars...

    $result=mysql_query("SELECT * FROM ".$program['table_name']." WHERE TO_DAYS(docdate) < = TO_DAYS(NOW()) ORDER BY docdate DESC",$con);
    //issue your sql query..


    if(mysql_num_rows($result)>0){
    //Yes ,record is availble.

    while ($row = mysql_fetch_array($result)) {

    $regs=explode('(',$row['body']);
    //seperate your body based on '(' using explode(),so you can get your first portion very easily..

    $star=$regs[0];
    //got the star..

    echo "<tr><td><a href="$PHP_SELF?star=$star&article=".$row['id']."">$star</a></td></tr>n";
    // now print your stars here..
    }
    }else{
    echo "Sorry!! no recordsn";
    }

    }else{

    ////here is your detailed display page..

    if(isset($star)){

    //$result=mysql_query("SELECT * FROM ".$program['table_name']." WHERE body like '$star%' AND id='$id'",$con);
    //search for your star at the begining of the body...

    $result=mysql_query("SELECT * FROM ".$program['table_name']." WHERE id='$id'",$con);

    // get the details using the unique id..so no need for star value here..
    //you don't have to use above query..

    $row=mysql_fetch_array($result);
    echo $star."n";

    $regs=explode(')',$row['body']);

    //this time seperate with ')'..
    echo $regs[1];
    // print the body here..

    }else{
    echo "errorn";
    exit;
    }
    }
    ?>

    i have not tested above script..
    tell me if you have any problem doing this..


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited July 24, 2000).]

Similar Threads

  1. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 11:56 AM
  2. File name explode and List
    By anr in forum PHP Development
    Replies: 5
    Last Post: November 23rd, 2003, 04:44 PM
  3. shorter way of writing this? (explode)
    By spybreak in forum PHP Development
    Replies: 12
    Last Post: September 29th, 2003, 05:06 PM
  4. ereg; matching * behind another ereg match
    By sankyu in forum PHP Development
    Replies: 5
    Last Post: April 7th, 2003, 04:52 PM
  5. Multiple separators with explode function???
    By Turannos in forum PHP Development
    Replies: 4
    Last Post: May 24th, 2001, 09:39 AM

IMN logo majestic logo threadwatch logo seochat tools logo