mysql - How to show Images calling from Database with PHP only one time -


When I paint images randomly, it loads them x times, but I want to show them only once I am $ random = array_rand (database :: query (select 'from ad')); $ Adv_sql = "Select 'from ad' where 'id` = $ random"; $ AdvResult = Database :: Single ($ adv_sql, $ random ['id']); $ AdvExplode = Explosion ('/', $ advResult ['Upload']); $ AdvLocation = 'url / location' end ($ advExplode);

I can not understand your abstraction.

Your second query has condition id = $ random , but you can tie parameters in your single () method: $ adv_sql , $ Random ['id'] .

We do not know the way in our own way, you should have shown us their implementation.

Anyway, is not a query better this? Select from to (

If you do not want to show a pre-filled image in the second request, you will need to log in to the image where it has been shown so far, based on the database, cookies or sessions < / P>


Or, bind to the pictures shown for example.

This is my test yet:

  class images {private $ _image Show = array ("''); personal function getShownImages () {return implode (' Private function setshot image ($ line) {$ this-> _imagesShow [] = $ line ['id'];} Public function getImages () {$ query = "SELECT id, where the images are not from images ({$ this-> getShownImages ()}); $ Result = mysqli_query ($ query); $ Line = mysqli_fetch_assoc ($ result); $ This- & gt; SetShownImage ($ line); $ Line refund; }} $ Img = new image (); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ()); Var_dump ($ img- & gt; getImages ());   

Output:

  array (size = 2) 'id' = & gt; String '1' (length = 1) 'IMG' => String '0.jpg' (length = 1) array (size = 2) 'id' = & gt; String '2' (length = 1) 'IMG' => String '1.jpg' (length = 1) array (size = 2) 'id' = & gt; String '3' (length = 1) 'IMG' => String '2.jpg' (length = 1) array (size = 2) 'id' = & gt; String '4' (length = 1) 'IMG' => String '3.jpg' (length = 1) array (size = 2) 'id' = & gt; String '5' (length = 1) 'IMG' => String '4.jpg' (length = 1) array (size = 2) 'id' = & gt; String '6' (length = 1) 'IMG' => String '12 .jpg '(length = 1) array (size = 2)' id '= & gt; String '7' (length = 1) 'IMG' =>   

Therefore getImages () returns a non-shown image of each call / html >

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -