1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Textbox Search

Discussion in 'PHP' started by le007, Feb 4, 2010.

  1. #1
    Hi all,

    I need a textbox that I can enter a number (a primary key) and produce the corresponding data with that primary key. If not an error message comes up.

    Anyone got the code?
    thanks
     
    le007, Feb 4, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Can you ellaborate?
     
    danx10, Feb 4, 2010 IP
  3. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What exactly do you need help with? This forum is for programmers who need help but we won't write scripts for you. Show us what you have so far and explain where you are having a problem and we will help you.
     
    risoknop, Feb 4, 2010 IP
  4. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    Thank you for the reply danx10,
    Basically what I want is:

    a textbox: [ ]
    enter a number
    [99] enter and whatever data is in the database where 99 is the auto incremented number, im not sure if thats called the primary key or what - but basically whatever is on line 99 will appear?

    I'm new to PHP, I hope I've explained myself sufficiently. Many thanks,
    Le007
     
    le007, Feb 4, 2010 IP
  5. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Risoknop, I know this: I've been a member for quiet some time now and am an absolute expert at CSS, I've not only written code for people but have emailed them bespoke templates specific to them - I'm just looking for someone to do the same with this short script for me.
     
    le007, Feb 4, 2010 IP
  6. Mahir1505

    Mahir1505 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Number:<input type='text' name='number' value=''>
    $sql = mysql_query("SELECT * FROM `TABLE` WHERE id = '".$_POST['number']."' ");

    $show = mysql_fetch_array($sql);

    echo"".$show[id]."<br>
    ".$show[name]."<br>";

    something like this maybe?
     
    Mahir1505, Feb 4, 2010 IP
  7. meannn

    meannn Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Bencede bu iyi gibi. Mahir naber dostum :)
     
    meannn, Feb 4, 2010 IP
  8. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #8
    <form method="post">
    
    <input type="text" name="key" >
    
    <input type="submit" name="submit" value="Enter">
    
    </form>
    
    <?php
    if(isset($_POST['submit']) && ctype_digit($_POST['key'])){
    
    $row = mysql_fetch_array(mysql_query("SELECT * FROM your_table_name WHERE id={$_POST['key']}"));
    
    echo $row['the_column_name'];
    }
    ?>
    PHP:
     
    danx10, Feb 4, 2010 IP
  9. Mahir1505

    Mahir1505 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    What the hell does that means?
    english maybe?

    stay ontopic, pm me...
     
    Mahir1505, Feb 4, 2010 IP
  10. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #10
    Excellent, thanks guys - it'll work perfectly!
     
    le007, Feb 4, 2010 IP
  11. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #11
    It's Turkish. Mahir is a common name in Turkey so he probably thought you'd understand.
     
    SmallPotatoes, Feb 4, 2010 IP
  12. Mahir1505

    Mahir1505 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Nono i'm not turkish xD
    I'm bosnian but living in belgium :)
     
    Mahir1505, Feb 5, 2010 IP
  13. Imless

    Imless Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13


    whats the purpose of this? *ctype_digit* , it performs the search action without clicking the button? am I right?
    thanks anyways for this share.
     
    Imless, May 17, 2012 IP