Hi This is ScorpionZ
I have created my Webpage in Which i want to show a randomly generated banners...
The Scenario is simple
I have a banners name stored in Database.. Now I want to call them at Particular place with
selected Id's, Like there are 1 to 100 banners name and i want to call only 1, 5, 9,10,15,20
like this means only selected and randomly showed

Now here is the little piece of Code for that particular are where i want to show my Banners

  <?php
    $sql_view_flag_banners       =  "select * from flags_adds";
    $result_view_flag_banners   =   mysql_query($sql_view_flag_banners);
    while($rs_view_flag_banners=mysql_fetch_array($result_view_flag_banners))
    {
        $flg_id                =  $rs_view_flag_banners["flags_adds_id"];
        $flg_browse_nam        =  $rs_view_flag_banners["flag_browse_name"];
    }
  ?>
<!-- The above is the PHP CODE and below is an HTML -->
<td bgcolor="#EFEFE9">
   <div align="center"><img src="./uploaded_top_banner/<?php echo $prod_up_img; ?>" width="150px" height="100px"  />
   </div>
</td>

This code is only showing only 1 display but i want to show all randomly generated, even though i take a while loop to hold all of them.
Now Any Advancement in this code will be highly appreciated
I will be Thankful

Thanks and Regards
ScorpionZ

If you are storing the banner path in an array, you can use array_rand function to randomise the array. You can also use rand function to generate a random number and fetch that record number from the array.

where does $prod_up_img come from?You can use the rand() function in mysql so everytime you refresh the page different banners will be displayed.

$sql_view_flag_banners = "select * from flags_adds order by rand()";

Oh Sorry This is the Correctness... Thanks Mr.ryan_vietnow
<?php
$sql_view_flag_banners = "select * from flags_adds";
$result_view_flag_banners = mysql_query($sql_view_flag_banners);
while($rs_view_flag_banners=mysql_fetch_array($result_view_flag_banners))
{
$flg_id = $rs_view_flag_banners["flags_adds_id"];
$flg_browse_nam = $rs_view_flag_banners["flag_browse_name"];
}
?>
<!-- The above is the PHP CODE and below is an HTML -->
<td bgcolor="#EFEFE9">
<div align="center"><img src="./uploaded_top_banner/<?php echo $flg_browse_nam; ?>" width="150px" height="100px" />
</div>
</td>

To Naveen:
Yes I am only Storing then Particular name of my that Image or Banner. Let me Try ur Suggestions Naveen

To Mr.ryan_vietnow
Thanks for Your Advancement.
Let me Try this too.
Will get back soon

Regards ScorpionZ

Well MR Naveen and Mr.ryan_vietnow , I applied that
Now it is only Changing by refreshing the page means F5, but not automatically changing
Here is the Code:

<?php
        //$sql_view_flag_banners    =   "select * from flags_adds";
        $sql_view_flag_banners = "select * from flags_adds order by rand()";
        $result_view_flag_banners   =   mysql_query($sql_view_flag_banners);
        while($rs_view_flag_banners=mysql_fetch_array($result_view_flag_banners))
        {
        $flg_id     =   $rs_view_flag_banners["flags_adds_id"];
        $flg_browse_nam     =  $rs_view_flag_banners["flag_browse_name"];

        }   
  ?>

<td bgcolor="#EFEFE9">
<div align="center">
<img src="./uploaded_top_banner/<?php echo $flg_browse_nam; ?>" width="150px" height="100px"  />
</div>

</td>

you mean to show the banners like a .gif or something?

Like Not By Pressing F5 and see the Change but Change automatically by not F5...
means Automatically Banner changes...
Like i have 10 to 15 .gif in my DB and i want to show them randomly by not F5 but automatically changes
How to do that?

You have to use AJAX for that kind of thing.

Can u please Give me Some Reference to that?

Ok I will Check that ... and will get Back to You as early as i Can
Anyway Thanks So much for so much great Help

Thanks and Regards
ScorpionZ

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.