How to change a field content in a database for the search engine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Phaelle
    New Member
    • Jun 2007
    • 10

    How to change a field content in a database for the search engine

    hello

    I am doing a search engine for a library and I would like to offer the users the possibility of choosing a kind of document (video, audio, music sheet...) thanks to a check box . But the problem is that the kind of document in the database MySQL is named by an abbreviation (like "AV" for a a Video), which should not be seen on the result page. I would like that the full name "Video" is seen on the result page instead.
    But I can´t find out how I can write that code.

    I wrote that but it doesn´t work
    [code=php]
    if($_POST[`doc´]=="Video") {$sql="SELECT Tipo_de_documen to FROM tablabu LIKE "AV") }[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    Thanks for your help
    Last edited by pbmods; Jun 21 '07, 09:44 PM. Reason: Added CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    You posted this in the PHP Articles forum. I'll go ahead and move it to the PHP Forum so that you'll get some responses....

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Phaelle.

      Originally posted by Phaelle
      [code=php]
      if($_POST[`doc´]=="Video") {
      $sql="SELECT Tipo_de_documen to FROM tablabu LIKE "AV")
      }[/code]
      You'll be wanting to change that to:

      [code=sql]
      $sql = "SELECT `Tipo_de_docume nto` FROM `tablabu` WHERE `docTypeOrWhate verYouCalledIt` = 'AV'";
      [/code]

      Using LIKE is overkill, and you need to match against a field name. Also, you will want to put single quotes around 'AV' because you're using double quotes to set the value of $sql.

      Comment

      Working...