Jump to content

purplenewt

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by purplenewt

  1. thanks a ton guys I have been wrestling with this for weeks now and now its solved in about a 10th of the amount of code i was expecting:) much appreciated and thanks again. Purplenewt
  2. hi all, I am working on a project that must use only php (no database unfortunatly). It has to generate a selected number of random quotes but they must not repeat themselves. the quotes I have put into an array like so: <ul> 1.<?php echo ($quote[0]); ?> </ul> <hr /> <ul> 2.<?php echo ($quote[1]); ?> </ul> <hr /> <ul> 3.<?php echo ($quote[2]); ?> </ul> <hr /> <ul> 4.<?php echo ($quote[3]); ?> </ul> <hr /> and so on I know i need need to replace the numbers within the [] with a random number and I have a way to generate random numbers that do not repeat. Like so. <?php function rand_group($num) { $ary = range(1,50); shuffle($ary); return array_slice($ary, 0, $num); } echo implode(', ',rand_group(5)); ?> I just dont understand how i can get the numbers generated from this code into the [] to make sure i get no repeating quotes. I'm still very new at php but sometimes seems like i'm getting there just for hiccups like this to stump me totally. Any help would be greatly appreciated. Thanks Purplenewt
  3. Hi I am a bit new to php and have run into a problem, I need to generate a random number list on request from a user. eg, user selects 20 so I would need to have 20 unique random numbers from a range of 1-500. I tried to work things out and eventually after much trial and error, searching and deleting I found this here which is using random range and shuffle. Unfortunately this gives me 500 unique random numbers instead of 20 as I had hoped. <?php function rand_group() { $ary = range(1,500); shuffle($ary); return($ary); } echo implode(', ',rand_group(20)); ?> Any help would be great, this seems so close to what I need so I am thinking I am missing something really simple. Purplenewt
  4. if its just an image and you want centered and you are going to be declaring the height you could make the image into a background and then use the following css. background: url(image_name.jpg) center no-repeat #color; Hope this helps
  5. thanks a ton I followed the link you gave and found a better way to get the job done than I had thought of. I was thinking I would have to do a lot of if else type coding for each character that wasn't displaying properly, on the link you gave me I found: // Provides: You should eat pizza, beer, and ice cream every day $phrase = "You should eat fruits, vegetables, and fiber every day."; $healthy = array("fruits", "vegetables", "fiber"); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase); which with a small amount of editing has saved me a ton of coding. now I just have to find out how to mark this thread as solved:) Thanks again Purplenewt
  6. thanks I shall give that a try soon as I get the chance, unfortunatly ive just been called away to a job. thanks for your help. Purplenewt
  7. hi I kind of know what I need to achieve here just not sure how to accomplish it. Basically I have a text box and when users type into it it doesnt seem to understand characters like pound signs and things, so to fix this problem i am thinking some code that basically does something like: If £ found replace £ with £ and then repeat that for several character types but im just not sure how to go about it. Any help would be greatly appreciated, thanks. Purplenewt
  8. hello all, I will start by saying I am a php newb, been book learning a little while but struggling. I have been asked by my work to produce a kind of training website so I decided since I had started learning php I would use it. After a few attempts and not being able to get my head around certain problems I went looking for a 3rd party program, after much searching I found a linkware script that does everything I need for my project, used their demo and it was great (I got it from http://www.multiwebvista.com/testzone/download.php), so I downloaded it but cant seem to add questions to the mysql database using the admin that it comes with.I did manage to add subjects but couldnt add questions but to get that far I had altered a lot of the code and I am really not sure what I was doing so have reverted back to the original code to start again. I know any kind of walkthrough on getting this working is a is a massive ask but I am getting desperate, I tried emailing the original maker but it appears the contact details on his site are no longer valid. Any help you guys can give me would be much appreciated. Thanks Purplenewt
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.