how can i print db to screen

Discussion in 'Databases' started by emengen3, Dec 21, 2010.

  1. #1
    hello dear php coder im just new at php...and doing some examples..i have 3 page
    1-index.htm
    2-connect.php
    3-search.php

    when people search "name and surname" i want result print on screen ...i have user tables and there is 2 fields name and surname...please need some help its should be very easy for you...but very dffuclt for me :) thanks

    index.html
    <html>
    <head><title>Arama Yapma </title>
    </head><form action="search.php" name="ara" method="get">
      <input type="text" name="name" value="name" size="21">&nbsp;
      <input type="text" name="surname" value="name" size="21">&nbsp;
    <br>
    
    <input type="submit" name="ara" value="ara">
    <br>
    </form>
    </html>
    Code (markup):
    connect.php
    <?php
    $db = mysql_connect("localhost","xxxxx","xxxxxx");
    mysql_select_db("xxxx",$db);
    ?>
    
    Code (markup):
    search.php
    
    <?php 
    include("connect.php");
    [COLOR="darkred"]i need php code which it will take information from user tables name and surname fields and will print on screen [/COLOR]
    ?>
    
    Code (markup):

     
    emengen3, Dec 21, 2010 IP
  2. haa

    haa Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That's a programming question...?
     
    haa, Dec 23, 2010 IP
  3. makaleus

    makaleus Peon

    Messages:
    264
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    where is other table codes?
     
    makaleus, Dec 24, 2010 IP
  4. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #4
    This will display all names sorted by the surname. Look into a search form once you get this working.
    $people = mysql_query("SELECT [B]given_name[/B], [B]surname[/B] FROM [B]names_table[/B] ORDER BY [B]surname[/B]");
    while($person = mysql_fetch_assoc($people)){
    echo $person['[B]surname[/B]'].",".$person['[B]given_name[/B]']."<br>";
    }
    Code (markup):
    You'll need to change the emboldened values to match your field and table names. Good luck. ;)
     
    Alastair Gilfillan, Dec 25, 2010 IP