Page 1 of 1
help php mysql
Posted: Thu Sep 30, 2010 12:20 am
by Portnumbay
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
Re: help php mysql
Posted: Thu Sep 30, 2010 1:43 am
by requinix
What you do is change your HTML to something more reasonable:
Code: Select all
<input type="text" name="txtDesc[]" />
Repeat that as many times as you want - doesn't matter. $_POST["txtDesc"] will be an array of everything.
Re: help php mysql
Posted: Thu Sep 30, 2010 8:22 pm
by Portnumbay
for example i have something like this
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>
how to get it in post
is it like
or what ?
I tried but error..
thanks
Re: help php mysql
Posted: Thu Sep 30, 2010 8:58 pm
by requinix
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>
Portnumbay wrote:is it like
or what ?
It's
like that, yeah, except you're using the wrong variable. Variable names are case-sensitive in PHP.
Re: help php mysql
Posted: Fri Oct 01, 2010 6:07 am
by DigitalMind
following the previous post, $_Post != $_POST