Current location: Hot Scripts Forums » Programming Languages » PHP » random pic


random pic

Reply
  #1 (permalink)  
Old 03-17-08, 07:45 PM
techker techker is offline
Newbie Coder
 
Join Date: May 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
random pic

hey guys i made a store script and i would like to a rondom pic on the main page.

see i have 4 tables and in each i have an image.

in my sql
PHP Code:

$data mysql_query("SELECT `id`
FROM `store`
WHERE 1
LIMIT 0 , 1 " 
) or die(mysql_error()); 
but ionly see the same image 4 times?

in the tables

php
PHP Code:

echo '<a href="admin/info_product.php?id='$info['id'] .'"target="_blank"><img src="admin/getdata3.php?id='$info['id'] .'" border="0" alt="" /></a><br />'."\n"
works but i only see the same image over an over?

how can i extract a diffrent image?

Last edited by Nico; 03-18-08 at 10:48 AM.
Reply With Quote
  #2 (permalink)  
Old 03-17-08, 09:43 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Hmm, do you have 4 seperate tables, or 4 entries in one table?
If it's one table, then your mysql statement should look something like
sql Code:
  1. SELECT `id`
  2. FROM `store`
  3. LIMIT CEIL(RAND() * 4) , 1
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #3 (permalink)  
Old 03-18-08, 05:06 AM
techker techker is offline
Newbie Coder
 
Join Date: May 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
that gives me a random pic.thats good but it is the same pic in all the boxes?

see i have a bottom footer with 4 square boxes that i wan't pics to show in each.
Reply With Quote
  #4 (permalink)  
Old 03-18-08, 10:47 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
sql Code:
  1. SELECT `id` FROM `store` ORDER BY RAND() LIMIT 4

Then use a loop to output the table with the images. Otherwise you'll only get one image.
Reply With Quote
  #5 (permalink)  
Old 03-18-08, 05:10 PM
techker techker is offline
Newbie Coder
 
Join Date: May 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
hen use a loop to output the table with the images. Otherwise you'll only get one image.

thats the part the is messing me up?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random signature image script? with extras Dr_Frankenstein Script Requests 0 02-15-06 07:38 AM
Script that can do this... (inst. PIC) kartem Script Requests 2 09-14-05 03:39 AM
random image with random text/quote gx10vn PHP 4 10-22-04 08:30 AM
Random PHP include brduran PHP 4 08-16-04 06:34 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 07:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.