Defferent pats of same php file :?

GT9

Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    මචන්ලා අදත් මට පොඩි php ප්‍රශ්නයක්.. මේ ප්‍රශ්නය php file එකක වෙනම දත්ත පෙන්වන විදයක් ගැන... සරළ උදාරහණයක් කියනව නම්..

    අපි හිතමූ මෙවැනි පේජ් එකක් තියෙනවා කියලා.

    http://example.com/about.php

    ඉතින් මේ about.php පේජ් එකේ තියෙනවා... sample text එකක්...

    නමුත් මට ඕනේ මේ පේජ් එකට අදාලවම වෙනත් තොරතුරු ටිකක් පෙන්නන්න ඕන වෙනම පේජ් එකක් විදියට..

    මෙන්න මේවගේ...

    http://example.com/about.php?another=text හෝ..
    http://example.com/about.php?page=2

    මම දන්නව ගොඩක් මේ වගේ පේජස් වැඩ කරන්නේ sql database වලින් නේ... නමුත් මම හදන්නේ flat file database එකක්.. ඇත්තටම ඩේට තියෙන්නේ php file වල..

    ‍මචන්ලා මේවගේ දෙයක් කරන්න පුලුවන්ද? :P :D
     

    rskoora

    Well-known member
  • Apr 1, 2008
    4,001
    608
    113
    if($_GET['page'] == 2){

    // show some text

    }elseif($_GET['page'] == 3){

    // show another text

    }

    ???
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    if($_GET['page'] == 2){

    // show some text

    }elseif($_GET['page'] == 3){

    // show another text

    }

    ???

    ඔහ්... වෙනද වගේම.. ඔන්දස්පොට්.. :D :love:

    වැඩේ ගොඩ අයියා... ඔයාට රොම්බ තෑන්ක්ස්.. :P :D
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]

    තෑන්ක්ස් අයියා.. පට්ට පොත් සෙට් එක.... :love::P

    අයියා අයිය දුන්න කෝඩ් එක මම ටෙස් කරා... නමුත් කෙලින්ම php file එක call කරාම error එකක් එනවනේ.. ඒක හදාගන්නේ කොහොමද?

    <?php

    $page = $_GET['page'];
    if($page == 2){

    echo "page 2";

    }elseif($page == 3){

    echo "page 3";

    }
    ?>

    ඔය කෝඩ් එකේදී.. මම

    http://localhost/myphp/tipo23.php?page=2
    http://localhost/myphp/tipo23.php?page=3

    කෝල් කරාම page 2, page 3 print වෙනවා..

    හැබැයි මම..

    http://localhost/myphp/tipo23.php

    ගැහුවම... error ekak එනවා.. Notice: Undefined index: කියලා..

    මෙතනදි මට ඕන..http://localhost/myphp/tipo23.php තියෙන text ටික පෙන්න ගන්න...

    මේක කරන්න පුලුවන් විදියට කෝඩ් එක මොඩිෆයි කරල දෙනවද? :P
     

    rskoora

    Well-known member
  • Apr 1, 2008
    4,001
    608
    113
    තෑන්ක්ස් අයියා.. පට්ට පොත් සෙට් එක.... :love::P

    අයියා අයිය දුන්න කෝඩ් එක මම ටෙස් කරා... නමුත් කෙලින්ම php file එක call කරාම error එකක් එනවනේ.. ඒක හදාගන්නේ කොහොමද?

    <?php

    $page = $_GET['page'];
    if($page == 2){

    echo "page 2";

    }elseif($page == 3){

    echo "page 3";

    }
    ?>

    ඔය කෝඩ් එකේදී.. මම

    http://localhost/myphp/tipo23.php?page=2
    http://localhost/myphp/tipo23.php?page=3

    කෝල් කරාම page 2, page 3 print වෙනවා..

    හැබැයි මම..

    http://localhost/myphp/tipo23.php

    ගැහුවම... error ekak එනවා.. Notice: Undefined index: කියලා..

    මෙතනදි මට ඕන..http://localhost/myphp/tipo23.php තියෙන text ටික පෙන්න ගන්න...

    මේක කරන්න පුලුවන් විදියට කෝඩ් එක මොඩිෆයි කරල දෙනවද? :P

    <?php

    $page = $_GET['page'];
    if($page == 2){

    echo "page 2";

    }elseif($page == 3){

    echo "page 3";

    }else{

    // will print if there is nothing in page

    echo "tipo.php";

    }


    ?>

    notice 1 nam ene na mea code 1n .. notice 1 enawa atthe wena kohen hari
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    <?php

    $page = $_GET['page'];
    if($page == 2){

    echo "page 2";

    }elseif($page == 3){

    echo "page 3";

    }else{

    // will print if there is nothing in page

    echo "tipo.php";

    }


    ?>

    notice 1 nam ene na mea code 1n .. notice 1 enawa atthe wena kohen hari


    තෑන්ක්ස් අයියා රිප්ලයි එකට.. මට ඕනේ මෙන්න මේවගේ...

    example.com ගියාම.. example.com root එකේ තියෙන Index.php file එකේ text ටික විතරක් පෙන්නන්න..

    ඒ වගේම..

    example.com/?page=contact
    ගියාම contact එ‍කේ තියෙන text ටික විතරක් පෙන්නන්න...

    ඒ වගේම. කවුරු හරි වැරදි Index එකක් දුන්නොත්.... අපි හිතමු..

    example.com/?page=lajfladfjlakf කියලා... එතකොට එයාව. 404 error page එකට යවන්න...

    මට විශේෂයෙන්ම ඕනේ.. කෙලින්ම directory එකට කෝල් කරන්න පුලුවන් වෙන්නන මෙන්න මේ වගේ...

    example.com වගේ....

    example.com/?page=index මේවිදියට මම කැමති නෑ...:( නමුත් වෙනත් පේජස්....

    example.com/?page=about
    example.com/?page=contact
    example.com/?page=gallery

    වගේ පෙන්නුවට අවුලක් නෑ....

    මේ විදියට කරගන්න පුලවන් කෝඩ් එකක මට හදල දෙන්නකෝ අයියේ....:) :D
     

    danu91

    Well-known member
  • May 9, 2009
    1,108
    64
    48
    $page = $_GET['page'];

    if ($page == 1){
    //do some shit
    } else if ($page == 2){
    //
    }


    or use "switch"

    OR USE AJAX / JQUERY "POST" method..
    check w3schools
     
    Last edited:

    rskoora

    Well-known member
  • Apr 1, 2008
    4,001
    608
    113
    තෑන්ක්ස් අයියා රිප්ලයි එකට.. මට ඕනේ මෙන්න මේවගේ...

    example.com ගියාම.. example.com root එකේ තියෙන Index.php file එකේ text ටික විතරක් පෙන්නන්න..

    ඒ වගේම..

    example.com/?page=contact
    ගියාම contact එ‍කේ තියෙන text ටික විතරක් පෙන්නන්න...

    ඒ වගේම. කවුරු හරි වැරදි Index එකක් දුන්නොත්.... අපි හිතමු..

    example.com/?page=lajfladfjlakf කියලා... එතකොට එයාව. 404 error page එකට යවන්න...

    මට විශේෂයෙන්ම ඕනේ.. කෙලින්ම directory එකට කෝල් කරන්න පුලුවන් වෙන්නන මෙන්න මේ වගේ...

    example.com වගේ....

    example.com/?page=index මේවිදියට මම කැමති නෑ...:( නමුත් වෙනත් පේජස්....

    example.com/?page=about
    example.com/?page=contact
    example.com/?page=gallery

    වගේ පෙන්නුවට අවුලක් නෑ....

    මේ විදියට කරගන්න පුලවන් කෝඩ් එකක මට හදල දෙන්නකෝ අයියේ....:) :D


    itin ban kalin code 1 n karana puluwan ne :P

    $page = $_GET['page'];
    if($page == "about"){

    include "about.php";

    }elseif($page == "contact"){

    include "contact.php";

    }else{

    // this will be root

    include "root.php";
    }

    mea code 1 poddak eheta meheta karala hadaganin :P
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    $page = $_GET['page'];

    if ($page == 1){
    //do some shit
    } else if ($page == 2){
    //
    }


    or use "switch"

    OR USE AJAX / JQUERY "POST" method..
    check w3schools

    thankz machan reply ekata me widiya mama kalin try kara... මේ ත්‍රෙඩ් එකේ පළවෙනි පේජ් එකේ අවසානෙට මම දාපු රිප්ලයි එකේ තියෙනව මෙක වෙනස් කරගන්න ඕන විදියට.. මේ කෝඩ් එක අවුලක් නෑ. පොඩි වෙවසක් කරගන්න ඕන... :)
     

    hirashgeff

    Well-known member
  • Jan 16, 2007
    22,151
    25,862
    113
    28
    ලොවෙත් නැති තැනක
    තෑන්ක්ස් අයියා රිප්ලයි එකට.. මට ඕනේ මෙන්න මේවගේ...

    example.com ගියාම.. example.com root එකේ තියෙන Index.php file එකේ text ටික විතරක් පෙන්නන්න..

    ඒ වගේම..

    example.com/?page=contact
    ගියාම contact එ‍කේ තියෙන text ටික විතරක් පෙන්නන්න...

    ඒ වගේම. කවුරු හරි වැරදි Index එකක් දුන්නොත්.... අපි හිතමු..

    example.com/?page=lajfladfjlakf කියලා... එතකොට එයාව. 404 error page එකට යවන්න...

    මට විශේෂයෙන්ම ඕනේ.. කෙලින්ම directory එකට කෝල් කරන්න පුලුවන් වෙන්නන මෙන්න මේ වගේ...

    example.com වගේ....

    example.com/?page=index මේවිදියට මම කැමති නෑ...:( නමුත් වෙනත් පේජස්....

    example.com/?page=about
    example.com/?page=contact
    example.com/?page=gallery

    වගේ පෙන්නුවට අවුලක් නෑ....

    මේ විදියට කරගන්න පුලවන් කෝඩ් එකක මට හදල දෙන්නකෝ අයියේ....:) :D
    Dispatcher paatern eken oka karanbna puluwan eth tikak advanced
    ]
     

    Xxo0oxX

    Member
    Oct 2, 2012
    1,585
    114
    0
    itin ban kalin code 1 n karana puluwan ne :P

    $page = $_GET['page'];
    if($page == "about"){

    include "about.php";

    }elseif($page == "contact"){

    include "contact.php";

    }else{

    // this will be root

    include "root.php";
    }

    mea code 1 poddak eheta meheta karala hadaganin :P

    මෙයට ගෙඩිය පිටින් දන්නා හොද නැ එතකොට කවදාවත් ඉගෙන ගන්නේ නම් නෑ :rolleyes:
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    itin ban kalin code 1 n karana puluwan ne :P

    $page = $_GET['page'];
    if($page == "about"){

    include "about.php";

    }elseif($page == "contact"){

    include "contact.php";

    }else{

    // this will be root

    include "root.php";
    }

    mea code 1 poddak eheta meheta karala hadaganin :P

    ඔව් අයියා මෙතනදි root එකට යන්නේ... එන යූසර්.. browser address bar එකේ..

    example.com/?page=ladfjlkafa නැති ඉන්ඩෙක්ස් එකක් ගැහුවමනේ.. එන යූසර්.
    example.com කියල ගැහැව්වොත්... error එකක් ‍එනවා... මට ඕන... root එක කෙලින්ම කෝල් කරාම index එක පෙන්නන්න..

    මේ වගේ.. example.com :D

    මේ විදියට root එක access කරන්න මම කැමති නෑ... example.com/?page=index :(

     

    rskoora

    Well-known member
  • Apr 1, 2008
    4,001
    608
    113
    ඔව් අයියා මෙතනදි root එකට යන්නේ... එන යූසර්.. browser address bar එකේ..

    example.com/?page=ladfjlkafa නැති ඉන්ඩෙක්ස් එකක් ගැහුවමනේ.. එන යූසර්.
    example.com කියල ගැහැව්වොත්... error එකක් ‍එනවා... මට ඕන... root එක කෙලින්ම කෝල් කරාම index එක පෙන්නන්න..

    මේ වගේ.. example.com :D

    මේ විදියට root එක access කරන්න මම කැමති නෑ... example.com/?page=index :(


    mokadda error 1 ?? one nam is_set($page) hari if(strlen($page)) 1 hari dala check karapan oka podi deyak .. taniyama karala hadaganin :P :baffled::baffled:
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    mokadda error 1 ?? one nam is_set($page) hari if(strlen($page)) 1 hari dala check karapan oka podi deyak .. taniyama karala hadaganin :P :baffled::baffled:

    එළාස් අයියා..මම මේ හෙන ට්‍රයි එකක් දෙනවා. ගොඩදාගත්තොත් කියන්නම්... :love::P
     

    GT9

    Well-known member
  • Jun 22, 2013
    1,564
    167
    63
    [email protected]
    හප්පේ....ඔන්න කොහොම හරි වැඩේ ගොඩදාගත්ත... rskoora අයියා ඇතුලු.. උදව්කරන්න ආපු හැමෝටම ගොඩක් ස්තූතියි.. :love::P :D