Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Randon Records

New Here ,
Aug 08, 2008 Aug 08, 2008
I am very new to PHP, Until now I have been simply a designer and delved mainly in the graphical end of web design. I have my own web site I am building and am trying to figure out how to get something to work.

I have an area where I want to display three random thumb nails (I have them stored as thumbs PHP does not need to resize them). I am pulling the the jpeg name from my database. I have gotten it to sort of work. Its displaying 3 pictures. Its does randomize when I refresh, however all three images are the same. How can I get it to display 3 different images randomly?

I would Appreiate any help

My SQL Code is as follows:
TOPICS
Server side applications
225
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 08, 2008 Aug 08, 2008
Rabastan99 wrote:
> Its displaying 3
> pictures. Its does randomize when I refresh, however all three images are the
> same. How can I get it to display 3 different images randomly?

You're displaying only the first result. Instead of hard-coding three
images into your table cell, you need to insert one, and apply a repeat
region to the dynamic placeholder.


<td width="415" height="125" colspan="4" rowspan="4" align="center"
valign="middle" bgcolor="#151822">

<?php do } ?> // repeat region starts here
<img src="<?php echo $row_rsHIGHLIGHTS['websiteTHUMB']; ?>"
alt="random image">
<?php while ($row_rsHIGHLIGHTS = mysql_fetch_assoc($rsHIGHLIGHTS)); ?>

</td>

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 08, 2008 Aug 08, 2008
Thanks for the reply,

I tried a repeat region before, it insisted on laying them out vertically. I need them horizontal. I did try to copy and paste you code in and got a blank white page. I added code to show errors at the top of the page and got nothing.

Jon
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 08, 2008 Aug 08, 2008
Rabastan99 wrote:
> I tried a repeat region before, it insisted on laying them out vertically.

If that's the case, you applied the repeat region incorrectly.


> I did try to copy and paste you code in and got a blank
> white page. I added code to show errors at the top of the page and got nothing.

That suggests a PHP syntax error. I was simply adapting your script, and
it's possible that I omitted a quote or semicolon somewhere. The
following code is taken from a test page that I have just created, and
it definitely works, but you'll need to adapt it to your recordset and
file structure.

<td>
<?php do { ?>
<img src="images/<?php echo $row_getThumbs['image']; ?>" alt="random
image" />
<?php } while ($row_getThumbs = mysql_fetch_assoc($getThumbs)); ?>
</td>

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 08, 2008 Aug 08, 2008
LATEST
Thank You So Much!!

Now all I have to do is get them Linked LOL
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines