To use php include more than one ...

Discussion in 'PHP' started by OPETH, Jan 12, 2008.

  1. #1
    I have index.php,search.php and read.php files.

    I want to locate in index.php, other files.

    index.php codes:

    ........................................................................
    ........................................................................

    <form method="POST" action="search.php" >
    <input type="text" name="word" class="aramakutusu "/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Ara"
    class="aramabutonu "/>
    </form>

    ........................................................................
    ........................................................................

    I have tried that:
    <?php
    
    switch(word)
    {
    
    case word:
    include('search.php');
    break;
    default:
    include('read.php');
    }
    ?>
    Code (markup):
    I want to locate in index.php read.php and search.php.How I will make it?
     
    OPETH, Jan 12, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    switch($_POST['word'])
    
    PHP:

    
    case 'word':
    
    PHP:
     
    nico_swd, Jan 12, 2008 IP
  3. OPETH

    OPETH Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    
    [CODE]<?php
    
    switch($_POST['kelime'])
    
    {
    
    case 'kelime':
    include('search.php');
    break;
    default:
    include('read.php');
    }
    
    Code (markup):
    I have'nt a problem syntax that like it.

    I want to appear in index.php the file named "search.php" .

    <form action=''search.php"........>
     
    OPETH, Jan 12, 2008 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Lol, thats a pretty strange request.

    Make it action="#" or something.
     
    MMJ, Jan 12, 2008 IP
  5. OPETH

    OPETH Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I solution the problem.

    <?php
    
    
    	switch($_GET['page'])
    {
    	case 1:include("search.php");break;
    	case 2:include("read.php");break;
    	default:include("content.php");break;
    	}	
    
    
    ?>
    
    Code (markup):
    action="index.php?page=1"
     
    OPETH, Jan 13, 2008 IP
  6. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Why not just use an if loop instead of a switch?
     
    phpl33t, Jan 13, 2008 IP
  7. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There's no such thing as an if loop. And this is exactly what switch is made for.
     
    SmallPotatoes, Jan 13, 2008 IP