javascript - integrate an image with link -



javascript - integrate an image with link -

well, think might easier explain question image below:

as can seen in picture, if user select "by title", textbox appeared user can write film title (i used jquery auto-completion textbox). then, if user click on button "movies title", new window shown there list of movies containing term in textbox.

my question:

i integrate little image of each of these movies beside them (and maybe other info film year, genre..) amazon (please see here). used renderitem auto-complete part , works fine, have no thought how same in new window.. grateful if can help me.

this code:

<div id="m_scents" class="field"> <label style="margin-bottom:10px;" for="m_scnts"></label> <input class="autofill4" type="textbox" name= "q27[]" id="q" placeholder="enter film titles here" /> <input type="button" value="movies title" id="btnmove" style="display:none;"/> </div> <script type="text/javascript"> var selected; $(document).ready(function () { $("input[id='selecttype']").change(function(){ if ($(this).val() == "bytitle") { $("#m_scents2").hide(); $("#btnmove").show(); $("#m_scents").show(); $("#q").focus(); $("#q").autocomplete({ minlength: 0, delay:5, source: "query.php", focus: function( event, ui ){ event.preventdefault(); homecoming false; }, select: function( event, ui ) { window.selected = ui.item.moviename; homecoming false; } }).data("uiautocomplete")._renderitem = function( ul, item ) { homecoming $("<li></li>") .data( "item.autocomplete", item ) .append( "<a>" + (item.posterlink?"<img class='imdbimage' src='imdbimage.php?url=" + item.posterlink + "' />":"") + "<span class='imdbtitle'>" + item.moviename + "</span>" + "<div class='clear'></div></a>" ) .appendto( ul ); }; } }); $('#btnmove').on('click', function (e) { popupcenter("moviebytitle.php","_blank","400","400"); }); </script>

this moviebytitle.php:

<body> <div id= "field" </div> <script type="text/javascript"> var selected = parent.window.opener.selected; $.ajax({ url: 'childfilm.php', datatype: "json", data:{p:selected}, success: function(response) { $("#field").html(response); } }); </script> </body>

and childfilm.php:

<?php if(isset($_get['p']) && !empty($_get['p'])){ try{ include('imdbconnection.php'); $sql = $conn->prepare("select distinct moviename films moviename :p"); $sql->execute(array(':p' => '%'.$_get['p'].'%')); while($row = $sql->fetch(pdo::fetch_assoc)){ $option = '<a href=movie.php?title="' . $row['moviename'] . '">' . $row['moviename'] . '</a><br />'; $html .= $option; } } catch(pdoexception $e){ echo 'error: ' . $e->getmessage(); } echo $html; exit; } ?>

update:

this new childfilm.php (thanks @ghost help):

if(isset($_get['p']) && !empty($_get['p'])){ include('imdbconnection.php'); $sql = $conn->prepare("select distinct moviename films moviename :p"); $sql->execute(array(':p' => '%'.$_get['p'].'%')); } ?> <table> <tr> <th></th> <th>title</th> <th>year</th> <th>genre</th> </tr> <?php while($row = $sql->fetch(pdo::fetch_assoc)): ?> <tr> <td><img class='imdbimage' src='imdbimage.php?url="<?php echo $row['posterlink'];?>'</td> <td><a href="movie.php?title=<?php echo urlencode($row['moviename']); ?>"><?php echo $row['moviename']; ?></a></td> </tr> <?php endwhile; ?> </table>

and imdbimage.php:

<?php header("content-type: image/jpeg"); $url = rawurldecode($_request['url']); echo file_get_contents($url); ?>

new problem:

this result (still, image not shown properly):

if got info in table, include in fetching , nowadays in tabular form:

<?php if(isset($_get['p']) && !empty($_get['p'])){ include('imdbconnection.php'); $sql = $conn->prepare("select distinct moviename films moviename :p"); $sql->execute(array(':p' => '%'.$_get['p'].'%')); } ?> <table> <tr> <th></th> <th>title</th> <th>year</th> <th>genre</th> </tr> <?php while($row = $sql->fetch(pdo::fetch_assoc)): ?> <tr> <td><img src="path/to/images/<?php echo $row['filename']; ?>" alt="" /></td> <td><a href="movie.php?title=<?php echo urlencode($row['moviename']); ?>"><?php echo $row['moviename']; ?></a></td> <td><?php echo $row['year']; ?></td> <td><?php echo $row['genre']; ?></td> </tr> <?php endwhile; ?> </table>

javascript php jquery html mysql

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -