Need Help With Select From MySql

Discussion in 'PHP' started by DjZoC, Jun 2, 2010.

  1. #1
    $dbname = 'videor';

    url: http://www.website.com/?videoVID=2

    -----------------------------------------------------------------------------------------------------------
    MySql DB Videor:

    VID____Active____Title_____Weburl___________AddDate_____ViewNumber_____UserIp
    1______0________Dogs____http://web.com____2010-06-01___2____________________
    2______0________Cat_____http://web2.com___2010-06-01___3____________________
    -----------------------------------------------------------------------------------------------------------

    how i can show if videoVID=2 | echo from dbname Title | what Title = Cat

    hope someone can help me with this, im new on this and im tryng to learn
     
    DjZoC, Jun 2, 2010 IP
  2. WebDeveloper2010

    WebDeveloper2010 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Would be something like,

    SELECT FROM dbname WHERE VID = 'idHere'
    Code (markup):
     
    WebDeveloper2010, Jun 2, 2010 IP
  3. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Im not sure I follow what you are trying to do - can you explain it a bit more?

    Do you mean something like;

    <?php
    if(!empty($_GET['videoVID']))
      {
    # if its user inputted values, make sure you validate it properly
      $value = $_GET['videoVID'];
      if(!is_numeric($value))
        $value = "'" . mysql_real_escape_string($value) . "'";
    
      $query = mysql_query("SELECT title FROM videor WHERE VID = $value");
      $result = mysql_fetch_array($query) or die (mysql_error());
      print_r($result);
      }
    
    ?>
    PHP:
     
    lukeg32, Jun 2, 2010 IP
  4. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    thanks lukeg32 that im tryng to make but i still have one problem

     $dbname = 'videor';
    
     $db_conn  = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
     $db_found = mysql_select_db($dbname);
    
    
     if(!empty($_GET['videoVID']))
      {
      # if its user inputted values, make sure you validate it properly
      $value = $_GET['videoVID'];
      if(!is_numeric($value))
        $value = "'" . mysql_real_escape_string($value) . "'";
    
      $query = mysql_query("SELECT Title FROM web_video WHERE VID = $value");
      $result = mysql_fetch_array($query) or die (mysql_error());
      print_r($result);
      }
    PHP:
    i add this code but is show me on the page " Array ( [0] => Cute Girl Lost In The Wood [Title] => Cute Girl Lost In The Wood ) " how i can make to show just " Cute Girl Lost In The Wood "
     
    Last edited: Jun 2, 2010
    DjZoC, Jun 2, 2010 IP
  5. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Change this line - this is just dumping the entire record set;

      print_r($result);
    PHP:
    to this;

    print $result['title'];
    PHP:
     
    lukeg32, Jun 2, 2010 IP
  6. DjZoC

    DjZoC Member

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    work thank you !!!! you save my day !!! thanks again
     
    DjZoC, Jun 2, 2010 IP