show homepage only php

Discussion in 'PHP' started by williamsweb, Sep 3, 2009.

  1. #1
    Hi
    I have a php based site- single page site ( but shows different data on each page from database quries).,, no script

    I want to show some stuffs on homepage only
    how can i do that?

    plz help
    thanks
     
    williamsweb, Sep 3, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Do you mean u are using get variables currently to display data ??
     
    Bohra, Sep 3, 2009 IP
  3. williamsweb

    williamsweb Active Member

    Messages:
    2,016
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    75
    #3
    I think yes
    display page is same, but there is a big database.
     
    williamsweb, Sep 3, 2009 IP
  4. AustinQPT

    AustinQPT Member

    Messages:
    75
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Check the link in my sig called naruto episodes I did what you are looking to do.

    You need to do a mysql query for the get variable then get the returned value from the database and insert that variable into the html of the page.

    to have multiple get values you can do..

    http://www.examplesite.com/test.php?get1=X&get2=Y&get3=Z

    then on the following page(ie: test.php) say
    $X = $_GET['1'];
    $Y = $_GET['2'];
    $Z = $_GET['3'];

    $X would return X
    $Y would return Y
    $Z would return Z

    then search the database for the value of the variable...

    WARNING THIS IS NOT SECURE...

    need more help send me a pm...
     
    AustinQPT, Sep 3, 2009 IP
  5. williamsweb

    williamsweb Active Member

    Messages:
    2,016
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    75
    #5
    but that code is an advertisement..
    i don't know how to do mysql
    anything simple?
     
    williamsweb, Sep 3, 2009 IP
  6. AustinQPT

    AustinQPT Member

    Messages:
    75
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #6
    I guess you could use text files, but honestly learning mysql is not nearly as hard as php...
     
    AustinQPT, Sep 3, 2009 IP
  7. Hanratty

    Hanratty Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    We can do this in two ways. We can either edit our theme and insert the ad code to show the ad or we can use a wordpress plugin called Whydowork Adsense to do this automatically. Let’s know both tricks step by step.

    Edit Theme to show Ads on Wordpress Homepage Only

    1. Login to your Wordpress dashboard
    2. Navigate to Appearance >> Editor >> Index.php
    3. Choose the location where you want to display the ad and paste the following code there

    <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
    YOUR ADVERTISEMENT CODE HERE
    <?php } ?>

    4. Replace the line YOUR ADVERTISEMENT HERE with your ad code.
    5. Save the changes and you are done.
     
    Hanratty, Sep 4, 2009 IP
  8. williamsweb

    williamsweb Active Member

    Messages:
    2,016
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    75
    #8
    I know about wordpress
    but this is not a wordpress.
    only simple index.php site
     
    williamsweb, Sep 4, 2009 IP
  9. yuvrajm

    yuvrajm Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    submit the ad code into your data base and take the id of that row.
    Now simply put this code in the block where you want to load the ad:
    
    $query = mysql_query("SELECT * FROM [i]table-name[/i] WHERE id='[i]id[/i]'");
    $result = mysql_fetch_array($query);
    echo $result['[i]variable[/i]'];
    
    Code (markup):
    another way which shall save database query shall be :
    
    echo "ENTER YOUR CODE HERE AND replace quotes with \"";
    
    Code (markup):
     
    yuvrajm, Sep 4, 2009 IP
  10. williamsweb

    williamsweb Active Member

    Messages:
    2,016
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    75
    #10
    but there is no such id on homepage.. its index.php page
     
    williamsweb, Sep 4, 2009 IP
  11. yuvrajm

    yuvrajm Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    How are you getting the content from the database? is that by while()...

    It shall be better if you can give a better overview of your script.
     
    yuvrajm, Sep 7, 2009 IP