Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
help a designer with some php tips

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
dr_Hate



Joined: 28 Aug 2007
Posts: 168
Location: Rijeka

PostPosted: 19.11.2009 00:21    Post subject: help a designer with some php tips Add user to your forum ignore list Reply with quote

u cemu je kvaka - radim online istrazivanje, i u jednom dijelu mi treba da se od 4 razlicita sadrzaja svakom posjetitelju/ispitaniku random prikaze jedan.

ono sto imam trenutno je:
Code:
$prikazi_content= rand(1, 4);
echo $content[$prikazi_content];


no problem je u tome ako mi osoba slucajlno lupi F5, gotovo sigurno ce se taj sadrzaj promijeniti. A to bas i ne zelim Smile

kopao sam po netu, no nisam bas nasao nesto sto bih mogao/znao iskoristit, pa ako ima dobra dusa za vjecnu slavu i hvalu bio bi jako sretan Wink

_________________
imam domenu |stajduhar.org|
Back to top
View user's profile Send private message Visit poster's website
gloin



Joined: 30 Apr 2006
Posts: 27
Location: Varaždin

PostPosted: 19.11.2009 09:26    Post subject: Add user to your forum ignore list Reply with quote

Pozdrav.
Ovo sam na brzinu.
Možda ima bolje riješenje al ovo radi.

Code:
<?php
session_start();

$num = rand (1,2);

if ($num == 1) {
   $sadrzaj = "sadrzaj1";
}
elseif ($num == 2) {
   $sadrzaj = "sadrzaj2";
}


if (isset($_SESSION['final'])) {
   $final = $_SESSION['final'];
}
else {
   $_SESSION['final'] = $sadrzaj;
   $final = $sadrzaj;
}

echo $final;
?>


Last edited by gloin on 20.11.2009 15:31; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Twitter profile
sphx



Joined: 02 Jun 2004
Posts: 109
Location: Split

PostPosted: 19.11.2009 17:13    Post subject: Add user to your forum ignore list Reply with quote

malo si previše zakomplicirao ali poanta je tu.

evo kako bih ja to rješio:

Code:
session_start();
if(!isset($_SESSION['content'])) {
    $_SESSION['content'] = mt_rand(1, 4);
}
   
echo $content[$_SESSION['content']];


hint: session_start(); se mora pozvati prije bilo kakvog outputa.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dr_Hate



Joined: 28 Aug 2007
Posts: 168
Location: Rijeka

PostPosted: 21.11.2009 18:56    Post subject: Add user to your forum ignore list Reply with quote

tnx, to je to sto mi je trebalo Smile

_________________
imam domenu |stajduhar.org|
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group