/    Sign up×
Community /Pin to ProfileBookmark

static previews

hello, how i can make a static previews to image?
i have images with tags for it (and some images without tags), i made a previews for them, but it dynamic previews, they withdraw from database by random. How it works: i take tags then withdraw all images with that tags from db and take a random row then in that row i take id of image and by that id a have a preview. How can a make a static previews select from database??

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ericatekkaOct 20.2011 — Do you have any code at the moment? Could create a materialized table view if you want it to be consistent for a certain time frame and reduce SQL load.
Copy linkTweet thisAlerts:
@ijsauthorOct 20.2011 — yes, thats my code
[code=php]$latest_tag_query = mysql_query("SELECT id_tag FROM tagsforimg WHERE id_image=current image id);
//tags for image

for ($preview_count = 1; $t = mysql_fetch_assoc($latest_tag_query); ++$preview_count){

$latest_tag_id[$preview_count]= $t['tag_id'];
}


$latest_num_rows = mysql_num_rows($latest_tag_query);
$preview_exist = 1;
while ($preview_exist <= $latest_num_rows){
$preview_tags[$exist] .= $latest_tag_id[$preview_exist];
if($latest_num_rows - $preview_exist > 0)
$preview_tags[$exist] .= ", ";
$preview_exist++;
} // we made a string like "tag, tag, tag"

$preview_query[$exist] = mysql_query("SELECT id_image FROM tagsforimg WHERE id_tag IN (".$preview_tags[$exist].") AND id_image!=current image id");

// we select all ids of images with that tags.


for ($pr_q_c = 1; $pr_mfa = mysql_fetch_array($preview_query[$exist]); ++$pr_q_c){

$pr_ph_id[$exist][$pr_q_c]= $pr_mfa[0];
}

$pr_rand_1[$exist] = rand(1, $pr_n_r);
do{
$pr_rand_2[$exist] = rand(1, $pr_n_r);}
while($pr_rand_1[$exist] == $pr_rand_2[$exist]);
do{
$pr_rand_3[$exist] = rand(1, $pr_n_r);}
while($pr_rand_1[$exist] == $pr_rand_3[$exist] OR $pr_rand_2[$exist] == $pr_rand_3[$exist]);
do{
$pr_rand_4[$exist] = rand(1, $pr_n_r);}
while($pr_rand_1[$exist] == $pr_rand_4[$exist] OR $pr_rand_2[$exist] == $pr_rand_4[$exist] OR $pr_rand_3[$exist] == $pr_rand_4[$exist]);

//4 random rows for next select


$pr_src_1[$exist] = mysql_query("SELECT url FROM images WHERE id=".$pr_ph_id[$exist][$pr_rand_1[$exist]]."");
$pr_src_2[$exist] = mysql_query("SELECT url FROM images WHERE id=".$pr_ph_id[$exist][$pr_rand_2[$exist]]."");
$pr_src_3[$exist] = mysql_query("SELECT url FROM images WHERE id=".$pr_ph_id[$exist][$pr_rand_3[$exist]]."");
$pr_src_4[$exist] = mysql_query("SELECT url FROM images WHERE id=".$pr_ph_id[$exist][$pr_rand_4[$exist]]."");

[/code]


sorry if i made some mistake with "{" and "}" , i remove some parts from it.
Copy linkTweet thisAlerts:
@swcOct 20.2011 — from where i can post new thread?sry. i m new.

my prob is:



<center><IFRAME

SRC="http://wixdemo.weebly.com/"

WIDTH=870 HEIGHT=650 margin-top:-200px;

SCROLLING=NO
>
<A HREF="http://wixdemo.weebly.com/">A

</A>

</IFRAME></center

how can i remove header of the original site?using iframe ...etc???!!!
Copy linkTweet thisAlerts:
@ijsauthorOct 30.2011 — does anyone know in what direction i must go, for resolving my problem with previews?
×

Success!

Help @ijs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...