Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2002
    Location
    Istanbul / Turkey
    Posts
    214

    I can't divide MySQL datas?

    Hi, There is a MySQL db I used for my program's index. For updates I open my tables like this;

    Index

    id cat list
    1 cat1 code1, code2, code3.....
    2 cat2 code1, code2, code3....


    I request list where the cat=cat1, it is OK but when I try to pair each of the code to the variables, but doesn't work.


    $connection = mysql_connect("localhost") or die ("Can\'t connect with the SQL server!");
    mysql_select_db("users");
    $query = "SELECT line FROM index WHERE cat='".$cat."'";
    $result = mysql_query($query, $connection) or die("Error in query: $query." . mysql_error());
    $splitter = ",";
    $newresult = split($splitter,$result);

    if ( $thumb == "1" ) { $initial = 1; }
    if ( $thumb == "2" ) { $initial = 9; }
    if ( $thumb == "3" ) { $initial = 17; }
    if ( $thumb == "4" ) { $initial = 25; }
    if ( $thumb == "5" ) { $initial = 33; }
    if ( $thumb == "6" ) { $initial = 41; }
    if ( $thumb == "7" ) { $initial = 49; }
    if ( $thumb == "8" ) { $initial = 57; }
    if ( $thumb == "9" ) { $initial = 65; }
    if ( $thumb == "10" ) { $initial = 73; }

    $frame1 = array_slice($result,1,1);
    if ( $frame1 == "" ) { $frame1="BLANK"; }
    $initial = $initial++;
    $frame2 = array_slice($newresult,$initial,1);
    if ( $frame2 == "" ) { $frame2="BLANK"; }
    $initial = $initial++;
    $frame3 = array_slice($newresult,$initial,1);
    if ( $frame3 == "" ) { $frame3="BLANK"; }
    $initial = $initial++;
    $frame4 = array_slice($newresult,$initial,1);
    if ( $frame4 == "" ) { $frame4="BLANK"; }
    $initial = $initial++;
    $frame5 = array_slice($newresult,$initial,1);
    if ( $frame5 == "" ) { $frame5="BLANK"; }
    $initial = $initial++;
    $frame6 = array_slice($newresult,$initial,1);
    if ( $frame6 == "" ) { $frame6="BLANK"; }
    $initial = $initial++;
    $frame7 = array_slice($newresult,$initial,1);
    if ( $frame7 == "" ) { $frame7="BLANK"; }
    $initial = $initial++;
    $frame8 = array_slice($newresult,$initial,1);
    if ( $frame8 == "" ) { $frame8="BLANK"; }



    thanks for your help.

  2. #2
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    3,100
    $newresult = split($splitter,$result);

    $result is just result resource id (like pointer to your data). To get acctual data you nedd to fetch it.
    $newresult = mysql_fetch_array($result) ;
    or something like that.

Posting Permissions

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