Finding a file with ID in PHP

Discussion in 'PHP' started by pukhtoogle, Aug 29, 2012.

  1. #1
    I am working on a dictionary application in PHP, where i want to put image with words, there is an issue for example i have a word


    dog
    there are 3 meaning of this word (for example)


    id - word
    1 - meaning 1
    2 - meaning 2
    3 - meaning 3


    i uploaded the image in /photos folder with id name (1.jpg), when i start the while loop it grab all the meaning and display.. but for the image it pick the final id like 3 which is also associated with dog but i want that the code check all the three id if find any one display the picture.
    
    $path = "photos/".$id.".jpg";
    using the function file_exists($path);
    
    
    
    Code (markup):
    Thanks
     
    pukhtoogle, Aug 29, 2012 IP
  2. InstaCoders

    InstaCoders Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well if you think about the theory and logic behind it, there are basically two things.

    1.) The category (dog)
    2.) The niche (which definition)

    So you have to apply that theory into your code as well.

    So if the id returns say '15' then you need to know if there are any extras to that category.
    So there has to be a way to check that. Either against a database query or scanning of the files.

    If it's a database query, check against the category id first and then check for subs
    if it's scanning the files, then you need to break up a file name and check.
     
    InstaCoders, Aug 29, 2012 IP
  3. pukhtoogle

    pukhtoogle Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Let me explain a bit more to clearify the problem.

    I have a word dad meaning ابا in Pashto language, i declared a file with name dad.png it working fine.
    Problem is when some one enter daddy it has the same meaning ابا in Pashto, if the grabbing of image is dynamic then it show the error. like

    First case: (Picture Showing)
    2nd case: (Picture Not-showing)
     
    pukhtoogle, Aug 29, 2012 IP
  4. phpking

    phpking Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    check the category again
     
    phpking, Aug 30, 2012 IP