Results 1 to 3 of 3

Thread: echo problem? can't select my data from mysql table

  1. #1
    Join Date
    Nov 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default echo problem? can't select my data from mysql table

    hello guru(s) and advance i have any problem with $_session

    can help me more for solution my problem.

    i use this code select.php
    Code:
    <?php
    session_start();
    include("../dbconfig.php");
    
    $examp = $_GET["q"]; //query number
    
    $page = $_GET['page']; // get the requested page
    $limit = $_GET['rows']; // get how many rows we want to have into the grid
    $sidx = $_GET['sidx']; // get index row - i.e. user click to sort
    $sord = $_GET['sord']; // get the direction
    .................
    search code ...................
    ................
    $idm = $_SESSION['id'];
    //SQL Statement
            $SQL = "SELECT * FROM 
    				tb_profile A 
    				INNER JOIN 
    				tbc_divisi B
    				ON 
    				A.id_divisi = B.id_divisi
    				INNER JOIN
    				tbc_status_aktif C
    				ON
    				A.id_statusaktif = C.id_statusaktif 
                                    WHERE id_p = ".$idm." ".$wh." ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit;
    ...................
    //SQL Query Statment
    ...................
    ?>
    i cant echo $idm;

    so i can't select my data from mysql table...

    can i use $_SESSION for this situation or anything else ??

    thx before.. please help me...

  2. #2
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Try using a " to close your $sql = statement after $limit ( $limit" ; )

    Why are you concatenating all the variables in the $sql string? I don't think you need to.

    Try:
    Code:
    $SQL = "SELECT * FROM 
    				tb_profile A 
    				INNER JOIN 
    				tbc_divisi B
    				ON 
    				A.id_divisi = B.id_divisi
    				INNER JOIN
    				tbc_status_aktif C
    				ON
    				A.id_statusaktif = C.id_statusaktif 
                                    WHERE id_p = '$idm'.'$wh' ORDER BY '$sidx'.'$sord' LIMIT $start , $limit" ;
    Actually, as I was putting this together, I realized I have no idea how the dark red portion of the above $sql string works.

    Repost the string with sample values. Like you would if you were using the MySQL command line or typing a query into phpmyadmin.

    I really don't think you need all those quotes in your string though. When putting integers into a mysql query, you shouldn't put quotes around them. (if you are using integers for id_p, etc)

    Jason

  3. #3
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    And for your $_SESSION variables in the query, you can do:

    Code:
    $q2 = "UPDATE `table`
    SET `column` = 'string'
    WHERE `column` = {$_SESSION['X']} LIMIT 1 " ;
    The above syntax is, strictly speaking, the most correct.

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
  •