Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    texas
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Can someone help me with displaying information?

    I have a website that is making some sort of a dictionary. Basically what I am doing is having everything display where the letter equals A.
    Here is my php code for the function
    Code:
    function display_db_table_dictionary($tablename, $connection,
                              $header_bool, $table_params)
    {
    	$word = "Word";
    	$Def = "Definition";
    	$firstLetter = "first_letter";
    	$table = "Dictionary";
    	$Letter = "A";
    	//echo ($word);
    	//$query_string = "SELECT * FROM Dictionary WHERE substring($word, 1, 1) = 'A'";
    	//$query_string = "select $word, $Def from $table where substring($word, 1,1) = 'A' ";
      	//$query_string = "select Word, first_letter from Dictionary";
    	$query_string = "SELECT * FROM table WHERE (name like '$A')"; 
    //	$query_string = "SELECT * FROM $table "; 
    //$query_string .= "WHERE $word LIKE 'A%'";
    
    	//$query_string = "select  $word $Def from $table where ($firstLetter = 'A')"
     	 //display_db_query($query_string, $connection,
           //            $header_bool, $table_params);
    }
    All of the commented lines are the sql commands that I have tried.
    thanks
    bri

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You can use mysql's LEFT function:
    [http://dev.mysql.com/doc/refman/5.0/...unctions.html]

    Good luck;

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    texas
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Okay I fixed some of my code

    Now it says...
    Code:
    $query_string = "SELECT * FROM $table WHERE ($word like 'A%')";
    thanks
    bri


  •  

    Posting Permissions

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