For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2004 > Re: [PHP-DB] How to define array variable while accessing it ???









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] How to define array variable while accessing it ???
Matt M.

2004-06-28, 4:05 pm

> <TD><DIV ALIGN="CENTER"> <input type="checkbox" name="<? printf("chk_arr[%d]",$i); ?>" value="<?=$row[0]?>" ></DIV></TD>

setup your checkbox something like this:

<input type="checkbox" name="delete[]" value="<?=$row[0]? />

php will treat this as an array
Torsten Roehr

2004-06-28, 4:05 pm

"Matt M." <h.dudeness@gmail.com> wrote in message
news:7d458020040628114862c2d150@mail.gmail.com...
printf("chk_arr[%d]",$i); ?>" value="<?=$row[0]?>" ></DIV></TD>[color=darkred]
>
> setup your checkbox something like this:
>
> <input type="checkbox" name="delete[]" value="<?=$row[0]? />
>
> php will treat this as an array


The closing php tag and quote of the value attribute was missing:

<input type="checkbox" name="delete[]" value="<?= $row[0] ?>" />

Regards, Torsten Roehr
Rinku

2004-06-29, 3:56 am

Actually I want to know how to access the variable
after defining it.
Like :
$query="delete from feedback where id=$delete[$i]";
$deleteresult=mysql_query($query) or
die("Unable to delete");

But here I am not getting any value in
"$delete[$i]"-(here $i is 0,1,2,3)

So what to do to access it ?
I cant access the value even by $_POST['$delete[$i]']

Can any of you suggest me the sollution ?

Rinku
--- Torsten Roehr <roehr@zilleon.com> wrote:
> "Matt M." <h.dudeness@gmail.com> wrote in message
> news:7d458020040628114862c2d150@mail.gmail.com...
> type="checkbox" name="<?
> printf("chk_arr[%d]",$i); ?>" value="<?=$row[0]?>"
> value="<?=$row[0]? />
>
> The closing php tag and quote of the value attribute
> was missing:
>
> <input type="checkbox" name="delete[]" value="<?=
> $row[0] ?>" />
>
> Regards, Torsten Roehr
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>





__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
Justin Patrin

2004-06-29, 3:56 pm

Well, IMHO you shouldn't do in-string variables as you never know if
it will work. In this case, it won't YOu should do something like
this:

$query='delete from feedback where id='.$delete[$i];

Single quotes tell PHP not to look for variables in the string. A
period concatenates. There's actually a better solution, too:

$query='delete from feedback where
id="'.mysql_real_escape_string($delete[$i]).'"';

On Tue, 29 Jun 2004 00:06:24 -0700 (PDT), Rinku <rinku_pgsql@yahoo.com> wrote:
>
> Actually I want to know how to access the variable
> after defining it.
> Like :
> $query="delete from feedback where id=$delete[$i]";
> $deleteresult=mysql_query($query) or
> die("Unable to delete");
>
> But here I am not getting any value in
> "$delete[$i]"-(here $i is 0,1,2,3)
>
> So what to do to access it ?
> I cant access the value even by $_POST['$delete[$i]']
>
> Can any of you suggest me the sollution ?
>
> Rinku
>
>
> --- Torsten Roehr <roehr@zilleon.com> wrote:
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail is new and improved - Check it out!
> http://promotions.yahoo.com/new_mail
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> !DSPAM:40e112fd156793833020386!
>
>



--
paperCrane --Justin Patrin--
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com