Hi again..
If i have about 10 textfields just say like
txtDesc1
txtDesc2
txtDesc3
txtDesc4
txtDesc5
...
txtDesc10
and i want to inser it into mysql.. how to do it use while or for ? whats the best..
thanks
help php mysql
Moderator: General Moderators
Re: help php mysql
What you do is change your HTML to something more reasonable:
Repeat that as many times as you want - doesn't matter. $_POST["txtDesc"] will be an array of everything.
Code: Select all
<input type="text" name="txtDesc[]" />-
Portnumbay
- Forum Newbie
- Posts: 14
- Joined: Mon Jul 05, 2010 1:22 am
Re: help php mysql
for example i have something like this
how to get it in post
is it like
or what ?
I tried but error..
thanks
Code: Select all
<form action="insert.php" method="post">
<label>
<input type="text" name="date[]" id="date[]">
</label>
<br>
<label>
<input type="text" name="date[]" id="date[]">
</label>
<br>
<label>
<input type="text" name="date[]" id="date[]">
</label>
<br>
<label>
<input type="submit" name="submit" id="submit" value="Submit">
</label>
</form>
is it like
Code: Select all
$tanggal = $_Post['date'];
I tried but error..
thanks
Re: help php mysql
IDs in HTML are supposed to be unique. Yours are not. I'm guessing you don't need them, but if you do then that's one place it's appropriate to use numbers.
Code: Select all
<form action="insert.php" method="post">
<label>
<input type="text" name="date[]" id="date1">
</label>
<br>
<label>
<input type="text" name="date[]" id="date2">
</label>
<br>
<label>
<input type="text" name="date[]" id="date3">
</label>
<br>
<label>
<input type="submit" name="submit" id="submit" value="Submit">
</label>
</form>It's like that, yeah, except you're using the wrong variable. Variable names are case-sensitive in PHP.Portnumbay wrote:is it likeor what ?Code: Select all
$tanggal = $_Post['date'];
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: help php mysql
following the previous post, $_Post != $_POST