User Profile

Collapse

Profile Sidebar

Collapse
Fynd
Fynd
Last Activity: Apr 15 '10, 02:44 PM
Joined: Mar 30 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Sorry for double posting but if I use this:
    Code:
    WHERE
                      a.kontrollerad = 'ja'  
                    GROUP BY
                      a.annonsid
                    ORDER BY
                      a.datumtid DESC
    The loop works with showing one image per id but if I do it like this:
    Code:
    WHERE
    					
                      a.kontrollerad = 'ja' 
    				$sokord
    				   
    				LIMIT
    ...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Hope it could shine a light on this but I could fetch the id from annonser_bilder for the different images but as they are connected to the same id from annonser I can not seperate them either. Tried the used_ids from above but can not make it to go further in the while loop from the query.
    Thanks for helping out.

    Best regards and happy easter.Morgan
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Ok here's the lot, hope it will make any sense to you :-)...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Yes bildpath is an array caught from the sql query. If I follow the output from the query, it tells me that there's 3 images with the same id because there are 3 images on that id but I only want to display the first image of that id.
    String(45) from above will be printed 3 times so the script actually is working as there are 3 writing in the same id. But the BIG question is how in *** do I print the first?

    Explanation: in the...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Anyone in for the issue? Or do you require more info?

    Best regards,
    Morgan
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Think my latest post vanished into cyberspace..... .........:-)
    I tried the loop for used_id above but still the output is as usual from var_dump($visa['bildpath']);

    bildpath is then string(45) and this string contains 3 items with different paths.


    So the trap for the id doesn't work as the id contains an image id that is unique in the same main id. If I could strip the string(45) into one? But I can not read...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Atli I have posted a long explanation but I think someone had to review it first, hadn't time to read the note when posting.
    Hope that works.

    Best regards,

    Morgan
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    God dag Atli,
    Well the application itself is a advertising script which contains a number of adverts. The info from the adverts are stored into 2 db's of the mysql database, 1 for the information about the advertiser etc, and 1 for the id, path and path name of the images stored with the adverts. This complicates things as I had to join 2 db's hence the code.
    The id of the advert, which is stored in the first db, can have multiple images...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Hi Markus,
    It seems like that the string I am searching, shows up as string46 when the var_dump($visa['bildpath']); is used but when using var_dump($visa['bildpath']['0']); I only get the single letters from the image path. In this case var_dump($visa['bildpath']['0']); will output string 1 "a" var_dump($visa['bildpath']['1']); will output string 1 "n" and so on.
    Well if we could find a way to output string46 one time...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Ok, here is the full query down to the img src. It will then continue showing the other arrays but I thought there was no meaning with that as the problem is located in the bildpath.
    The code is a mess right now and I haven't cleaned it up due to development so here it is:
    Code:
    $antal_bilder = ANTAL_SENAST_INLAGGDA_ANNONSER;
    
                  $sql = "
    
                    SELECT
    ...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Thanks Markus, if I LIMIT 1, I could not list the other records in my db as I now LIMIT with $offset,$number _of_records.
    I tried the [0] in my array but the VAR_DUMP came up with this:
    string(1) "a" string(1) "a" string(1) "a"
    It seams like the path to the image is lost. Any more ideas? Sorry to bother you with questions, but now I'm lost. I know and understand why it happens but to be able to make...
    See more | Go to post

    Leave a comment:


  • Fynd
    replied to How to get only the first path from Mysql?
    in PHP
    Thanks for your suggestions and reply. The VAR DUMP outputs this:
    Code:
    string(46) "annonsbilder/201003300702531217.210.81.146.jpg"  string(46) "annonsbilder/201003300658152217.210.81.146.jpg"  string(46) "annonsbilder/201003300829383217.210.81.146.jpg"
    I have 3 images in that id and I just wanna display the first. It should be OK with GROUP BY a.annonsid but doesn't work as I have a string in the WHERE...
    See more | Go to post

    Leave a comment:


  • Fynd
    started a topic How to get only the first path from Mysql?
    in PHP

    How to get only the first path from Mysql?

    Ok, let see if I can explain.
    I have a query from my db which inserts id of the inputted objects. The result is in a string which I use to show the content. In one of the sql tables, there are path names to images. One id can have up to 3 images assigned which gives 3 path names. But here is the catch, I only want to display the first path name. My query looks like this:
    Code:
    $data = "
                    SELECT
    ...
    See more | Go to post
No activity results to display
Show More
Working...