Jump to content

Foreach question


selenin

Recommended Posts

Hello, now I try it the other way, because my script is not working in IE with a jquery function and jquery I don't know, was already happy that I made it for Firefox, now I found out what's not working and have this little question, if I can make the echo out of the foreach function with all the values, my code:

 

$search->setsearchname($_POST['queryString']);
$results = $search->results ();

$i = 0;
foreach ($results as $res) {

    echo "<li> <a href='suggest.php?mid=".$res->imdbid()."'>".$res->title()." (".$res->year().")</li>";

    $i++;
    if ($i > 11) break;
}

 

Now I just need the echo out of the foreach with all values but don't know how to make it, if it's even possible

Link to comment
Share on other sites

foreach isn't the best method for what you are doing:

<?php

$search->setsearchname($_POST['queryString']);

$results = $search->results ();

for ($i=0;$i<11;$i++){

echo "<li> <a href=\"suggest.php?mid=".$res->imdbid()."\">".$res->title()." (".$res->year()."</a></li>";

}

Link to comment
Share on other sites

jonsjava it's not working, now it doesn't work in Firefox even, I don't know what's kind of array $results is that's what I get a part of:

 

array(20) { [0]=>  object(imdb)#3 (82) { ["version"]=>  string(5) "2.0.0" ["months:protected"]=>  array(12) { ["January"]=>  string(2) "01" ["February"]=>  string(2) "02" ["March"]=>  string(2) "03" ["April"]=>  string(2) "04" ["May"]=>  string(2) "05" ["June"]=>  string(2) "06" ["July"]=>  string(2) "07" ["August"]=>  string(2) "08" ["September"]=>  string(2) "09" ["October"]=>  string(2) "10" ["November"]=>  string(2) "11" ["December"]=>  string(2) "12" } ["imdbsite"]=>  string(13) "akas.imdb.com" ["pilotsite"]=>  string(17) "www.moviepilot.de" ["pilot_apikey"]=>  string(30) "50714a0681af531bc7cbb7355521b2" ["pilot_imdbfill:protected"]=>  int(0) ["cachedir"]=>  string(58) "/home/selenin/public_html/moviecommunity/imdbsearch/cache/" ["usecache"]=>  bool(true) ["storecache"]=>  bool(true) ["usezip"]=>  bool(true) ["converttozip"]=>  bool(true) ["cache_expire"]=>  int(3600) ["photodir"]=>  string(9) "./images/" ["photoroot"]=>  string(9) "./images/" ["imdb_img_url"]=>  string(7) "./imgs/" ["imdb_utf8recode"]=>  bool(false) ["debug"]=>  int(0) ["maxresults"]=>  int(20) ["searchvariant"]=>  string(0) "" ["lastServerResponse"]=>  string(0) "" ["revision"]=>  string(3) "362" ["imdbID"]=>  string(7) "0955308" ["page"]=>  array(23) { ["Title"]=>  string(0) "" ["Credits"]=>  string(0) "" ["CrazyCredits"]=>  string(0) "" ["Amazon"]=>  string(0) "" ["Goofs"]=>  string(0) "" ["Trivia"]=>  string(0) "" ["Plot"]=>  string(0) "" ["Synopsis"]=>  string(0) "" ["Comments"]=>  string(0) "" ["Quotes"]=>  string(0) "" ["Taglines"]=>  string(0) "" ["Plotoutline"]=>  string(0) "" ["Directed"]=>  string(0) "" ["Episodes"]=>  string(0) "" ["Trailers"]=>  string(0) "" ["MovieConnections"]=>  string(0) "" ["ExtReviews"]=>  string(0) "" ["ReleaseInfo"]=>  string(0) "" ["CompanyCredits"]=>  string(0) "" ["ParentalGuide"]=>  string(0) "" ["OfficialSites"]=>  string(0) "" ["Keywords"]=>  string(0) "" ["Awards"]=>  string(0) "" } ["akas"]=>  array(0) { } ["awards"]=>  array(0) { } ["countries"]=>  array(0) { } ["castlist"]=>  array(0) { } ["crazy_credits"]=>  array(0) { } ["credits_cast"]=>  array(0) { } ["credits_composer"]=> 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.