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

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

Daniel 27-02-10 15:13

דבר ראשון - אל תשתמש ב:
PHP קוד:

<?

אלא תמיד ב-
PHP קוד:

<?php

מטעמי תאימות.


ולנושא:
אתה כבר "בתוך" קוד PHP. תסתכל לדוגמא על הקוד הבא:
PHP קוד:

<?php
echo '
Test <?php echo $variable; ?>
'
;
?>

אתה כאילו פתחת תג PHP למרות שזה היה כבר פתוח.



כדי שיהיה לך יותר פשוט, אני ממליץ שתקרא על heredoc -
http://www.php.net/manual/en/languag...syntax.heredoc

dor77 27-02-10 15:37

ציטוט:

נכתב במקור על ידי MasterT (פרסם 756849)
דבר ראשון - אל תשתמש ב:
PHP קוד:

<?

אלא תמיד ב-
PHP קוד:

<?php

מטעמי תאימות.


ולנושא:
אתה כבר "בתוך" קוד PHP. תסתכל לדוגמא על הקוד הבא:
PHP קוד:

<?php
echo '
Test <?php echo $variable; ?>
'
;
?>

אתה כאילו פתחת תג PHP למרות שזה היה כבר פתוח.



כדי שיהיה לך יותר פשוט, אני ממליץ שתקרא על heredoc -
http://www.php.net/manual/en/languag...syntax.heredoc

נכנסתי ולא הבנתי את הבעיה שלי שם..
הבנתי שהבעיה היא שפתחתי php בתוך php..
אבל גם כשאני מסיר את התגי פתיחה וסגירה הבעיה נשארת.
מהי הצורה שאני אמור לכתוב את השורה?
אני כבר כמה ימים תקוע על הבעיה הזו..אשמח לעזרה.

תודה.

dor77 27-02-10 16:08

הצלחתי כמעט הכל..מחקתי את כל הקטע עם value וזה עובד.
אני פשוט צריך לדעת איך לכתוב את השורה של ה value בצורה תקינה עם כל הגרשיים שם.
מישהו יכול לנסות להסביר?
תודה.

liorclub 27-02-10 17:30

<?php
php code

?>
html code
<?php
php code
?>

אם אתה רוצה לשלב בתוך ה HTML לדוגמא:

<a href="<?php $variable ?>"> link </a>

dor77 28-02-10 00:30

תראו אני רוצה להציג משתנה בתוך הטופס.
להזכירכם הטופס כתוב בhtml ונמצא בתול php.
מה אני אמור לכתוב בשורה?

זה הקוד של כל הטופס:

PHP קוד:


echo <<<FORM


    <div id="form">
        <form action="" method="POST">
        <table id="registertable" cellpadding="10" border="0">
        <tr>
            <td align="left">
                <span class="field">First name:</span>
            </td>
            <td align="left">
                <input type="text" name="first_name" id="first_name" dir="ltr" value="$first_name"  style="width:200px; font-family:arial;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Last name:</span>
            </td>
            <td align="left">
                <input type="text" name="last_name" id="last_name" dir="ltr" style="width:200px; font-family:arial;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Username:</span>
            </td>
            <td align="left">
                    <input type="text" name="username" id="username" dir="ltr" style="width:200px;" maxlength="50">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password:</span>
            </td>
            <td align="left">
                <input type="Password" name="password" id="password" dir="ltr"  style="width:200px;" maxlength="15">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Password again:</span>
            </td>
            <td align="left">
                <input type="password" name="password_again" id="password_again" dir="ltr" style="width:200px;" maxlength="15">
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Email:</span>
            </td>
            <td align="left">
                <input type="text" name="email" id="email" dir="ltr" style="width:200px;" maxlength="30">
            </td>
        </tr>

        <tr>
            <td align="left">
                <span class="field">Country:</span>
            </td>
            <td align="left">  
                <select name="country" id="country" dir="ltr" style="font-family:arial;">
                    <option value=Country">Country</option>
                    <option value="Afghanistan">Afghanistan</option>
                    <option value="Zambia">Zambia</option>
                    <option value="Zimbabwe">Zimbabwe</option>
                    <option value="Other">Other</option>
                </select>
            </td>
        </tr>

        <tr>
            <td align="left">
                <span class="field">Date of birth:</span>
            </td>
            <td align="left">
                <select name="day" id="day" dir="ltr" style="font-family:arial;">
                    <option value="Day">Day</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="29">29</option>
                    <option value="30">30</option>
                    <option value="31">31</option>
                </select>
                <select name="month" id="month" dir="ltr" style="font-family:arial;">
                    <option value="Month">Month</option>
                    <option value="1">1</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                </select>
                <select name="year" id="year" dir="ltr" style="font-family:arial;">
                    <option value="Year">Year</option>
                    <option value="1940">1940</option>
                    <option value="1941">1941</option>
                    <option value="1998">1998</option>
                    <option value="1999">1999</option>
                    <option value="2000">2000</option>
                </select>  
            </td>
        </tr>
        <tr>
            <td align="left">
                <span class="field">Gender:</span>
            </td>
            <td align="left">
                <select name="gender" id="gender" dir="ltr" style="font-family:arial;">
                    <option value="Gender">Gender</option>
                    <option value="Male">Male</option>
                    <option value="Famle">Famle</option>
                </select>
            </td>
        </tr> 
        <tr>
            <td align="right"></td>
            <td align="center">
                <label>&nbsp; </label><input type="submit" name="submit" value="" id="submit" />
            </td> 
        </tr>
        </table>
        </form>
    </div>

FORM; 

תראו מה ניסיתי לעשות בשדה של first_name.
לא עובד..
אני כבר נמצא בPHP לכן אני לא פותח תג PHP וכותב echo.

מה הבעיה?

תודה רבה.

SniR-S 28-02-10 12:22

קודם כל אני שמח שהבנת את השלב הראשון והסתדרת ..
תשחק עם זה עוד אתה תלמד את כל השיטות לעשות מה שבא לך.

דבר שני, תכניס את המשתנים שלך בתוך סוגריים כאלו {}
לדוגמא:
PHP קוד:

{$first_name

זה יעבוד לך.


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

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