הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   בעיה בPHP (https://hosts.co.il/forums/showthread.php?t=18950)

x/1999 03-04-06 15:18

בעיה בPHP
 
אז ככה, בניתי מערכת ניהול תוכן.... אבל הבעיה היא שהתוכן של הדפים שמוסיפים בפאנל(הם קיימים על המסד והכל) לא נראה על הדפדפן. . .אני יודע שאני צריך לערוך את index.php בשביל שindex.php?page=X יעבוד, אבל מה אני צריך לכתוב ב index?

-roee- 03-04-06 15:53

PHP קוד:

<?php
///////////// index file


//$page = $_GET["page"];
if($page == "x"// if index.php?page=x, it will include x.php
{
@include(
"x.php");
} elseif(
$page == "news"// if index.php?page=news, it will include news.php
{
@include(
"news.php");
} elseif(
$page == ""// if isset page for index, it will print indextables.php
{
@include(
"indextables.php")
}
?>


BlueNosE 03-04-06 20:45

ציטוט:

נכתב במקור על ידי bigsmoke
PHP קוד:

<?php
///////////// index file


//$page = $_GET["page"];
if($page == "x"// if index.php?page=x, it will include x.php
{
@include(
"x.php");
} elseif(
$page == "news"// if index.php?page=news, it will include news.php
{
@include(
"news.php");
} elseif(
$page == ""// if isset page for index, it will print indextables.php
{
@include(
"indextables.php")
}
?>


ולמה לא פשוט לעשות
PHP קוד:

if (!empty ($_GET['page']))
@include_once (
$_GET['page'].".php");
else
@include_once (
"default.php"); 


Deagly 03-04-06 20:56

ציטוט:

נכתב במקור על ידי BlueNosE
ולמה לא פשוט לעשות
PHP קוד:

if (!empty ($_GET['page']))
@include_once (
$_GET['page'].".php");
else
@include_once (
"default.php"); 


כי אם זה לא בהכרח השם של הקובץ? :P

BlueNosE 03-04-06 21:01

אוקיי, קבל שיפור:
PHP קוד:

if (!empty ($_GET['page']))
{
if (
file_exists($_GET['page'].".php"))
@include_once (
$_GET['page'].".php"); 
else
{
if (
$_GET['page'] == "x")
@include_once (
"extra.php"); 
elseif (
$_GET['page'] == "y")
@include_once (
"why.php"); 
}
}
else 
@include_once (
"default.php"); 


בניה 03-04-06 21:25

ציטוט:

נכתב במקור על ידי x/1999
אז ככה, בניתי מערכת ניהול תוכן.... אבל הבעיה היא שהתוכן של הדפים שמוסיפים בפאנל(הם קיימים על המסד והכל) לא נראה על הדפדפן. . .אני יודע שאני צריך לערוך את index.php בשביל שindex.php?page=X יעבוד, אבל מה אני צריך לכתוב ב index?

לש"ש


הדפים שמורים על המסד? יש לכל דף שם או id?


כל הזמנים הם GMT +2. הזמן כעת הוא 20:50.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ