Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Ive wrote a small articles script here http://philbaucutt.co.uk/content/articles and would like to know how i can put php in the database so it gives the correct output.

    Im trying with this PHP

    PHP Code:
    <?php
    srand
    (time());
    $max=13// This is the number of photo you have in your directory (eg. numbered 1-50)
    $arr = array();
    while ( 
    count($arr) < $max ) {
    $x mt_rand(1,$max);
    if ( !
    in_array($x,$arr) ) { $arr[] = $x; }

    $p1 "photo_".$arr[0].".jpg";
    ?>
    <div style="text-align:center; padding-top:30px;">
    <img src="/images/random/<?php echo $p1 ?>" />

    <br /><br />


    You Are Viewing Picture <?php echo $arr[0?><br />
    How About Another? Just Hit F5

    </div>
    Regards Phil,


  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    I don't see the connection between the MySQL articles and
    the random .jpeg image. Are you trying to do a random article?


  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    If you're doing what I think you're doing in that loop, this is much more efficient: http://us.php.net/shuffle

    Your code gets exponentially more inefficient the more elements there are because the probability of in_array() returning true increases.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    I just wanted to run my entire site from a simple artciles/cms script but cant get it to output the correct data when using a php script.. it doesnt matter what the script is it still cleans the data ad converts all of the data into its html entities.



    filb i got the php script in the tutorials section so dont really know how it works i just know it works
    Regards Phil,


  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Phil ...

    This is probably too late to mention now,
    but I think Joomla is the answer for you.

    Before you dig in deeper, you might want
    to check it out.


  7. #6
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    used joomla and mambo before, I found too many restrictions as far as templating and didnt like the fact that they werent semantic so I wrote my own solution.
    Regards Phil,



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com