Thanks for that. Thats really helped me on my way. My understanding of php
is at the moment, basic, but in going to get there eventually!
Cheers again!
"David Mackenzie" <me@privacy.net> wrote in message
news:00p1201bnooefapkuo5t04js628cr58ju8@4ax.com...[color=blue]
> On Wed, 4 Feb 2004 03:46:44 -0000, "Steve Macleod"
> <steven_mac@leodhotmail.com> wrote:
>[color=green]
> >//need to loop through all the records and apply the SQL query
> >
> >for ( $marker=1; $marker<=$number_of_records; $marker++) {
> >
> >$sql = "UPDATE faq SET faq_quest='$_POST[txt_$marker]',
> >faq_ans='$_POST[txt_ans$marker]' WHERE faq_id =[/color][/color]
'$_POST[txt_ans$marker]'";[color=blue][color=green]
> >//code here to actually RUN the SQL query
> >}
> >
> >As you can probally guess from the fact that I am typing this massive[/color][/color]
post,[color=blue][color=green]
> >the above code does not work. I keep getting errors when I attempt to use
> >the $marker variable from within the SQL query, to cycle through all the
> >POST variables and update all the records. I think its to do with the[/color][/color]
single[color=blue][color=green]
> >quotes ', which tell the compiler not to process variables, but rather[/color][/color]
take[color=blue][color=green]
> >everything literally, so-to-speak.[/color]
>
> IMO, the worst thing that PHP does is this parsing of variables within
> string literals as it can lead to confusion.
>
> Anyway, to answer your query, use the concatenation operator "."
>
> $sql = "UPDATE faq SET faq_quest='".$_POST["txt_".$marker]."',
> faq_ans='".$_POST["txt_ans".$marker]."' WHERE faq_id =
> '".$_POST[txt_ans".$marker]."'";
>
>
http://www.php.net/manual/en/languag...ors.string.php
>
> I may have got one in the wrong place somewhere, but you get the
> general idea.
>
> I've just noticed you have single quotes around your primary key. Is
> your primary key a varchar? If not, the single quotes are not needed.
>
> --
> David ( @priz.co.uk )[/color]