0
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<form action="2.php" method="post">
<table width="400" border="0">
    <tr>
        <td>Ders sayisi :</td>
        <td><input type="text" name="sayi" /></td>
    </tr>
    <tr>
        <td><input type="submit" name="gonder" value="Gonder" /></td>

    </tr>
</table>
</form>
<?php
    if(isset($_POST['gonder']))
    {

        for($i=1;$i<=$_POST['sayi'];$i++)
        {
            echo "$i.ders"." "."<input type='text' **name='e$i'** />"."   -   "." 
            <select name='dersler'><option **value='a1'**>A1</option>
             <option **value='a2'**>A2</option><option **value='b1'**>B1</option>
             <option **value='b2'**>B2</option><option **value='c'**>C</option></select>"."<br>";
        }
    }
    //......
?>
</body>

Bold Text Here
How can I use html elements in echo command with php ? for example I want to calculate the average of lessons in these ones by using name tags.

3
Contributors
4
Replies
28
Views
4 Years
Discussion Span
Last Post by diafol
0

You can write out HTML tags in PHP as you would normally. The only thing you need to be aware of is by using speech marks you either need to escape them or use quotation marks instead. What I'm trying to say is you can't use the same set twice as you'll end up ending your echo before you meant to. I hope I explained that well?

Example of how not to do it:

echo("<div id = "DivisionTag" > Contents </div>");

Example of how to do it:

echo("<div id = 'DivisionTag' > Contents </div>");

Edited by Octet

0

You're questions doesn't make sense. Average of what?

name='e$i'

Is fine, what's the problem?

However,

<select name='dersler'>

needs to be:

<select name='dersler[]'>

But the whole page makes very little sense. You're creating select dropdowns OUTSIDE the form, or do not have form tags around the dropdowns. You have no submit button to go with them. I can't see any javascript, so I'm assuming this is a mistake?

0

I just tried to do that when I enter a number in textbox it gives to some textboxes and then how can I use created these textboxes for another processing ? Thank you for answers.

0

I just tried to do that when I enter a number in textbox it gives to some textboxes and then how can I use created these textboxes for another processing ? Thank you for answers.

Sorry, that doesn't make any sense to me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.