General queries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • UKuser

    #1

    General queries

    Hi Guys,

    I have some wierd MySQL queries. Although I am using ADODB (an
    abstraction layer) - the queries will probably be quite general.

    1) When I post data in a url (i.e. post.php?id=120 ) and I use this
    code: $var = secure_field($i d); it will work (on the
    "recieve_page.p hp"). However if I use $secure_field($ _POST['$id']) or
    any POST/GET/REQUEST type option, it won't work. Its fine, because
    secure_field does what I need, however I'm just not sure why its not
    picking it up. (If I probe $var - the result is blank)

    2) I have a table, where I want a delete button at the end of each row
    (as opposed to when only one record is displayed on the screen). I also
    don't want to have to post to an external delete.php file. Is there a
    way to do this?

    For example:
    print "<tr>
    <TD>{$rs->fields[0]}</TD>
    <TD>{$rs->fields[1]}</TD>
    <TD>{$rs->fields[2]}</TD>
    <TD>{$rs->fields[3]}</TD>
    <TD><a href='another_p age.php?id=$id' >Edit</a></TD>
    <TD><a href='this_page .php?id=$id2'>D elete</a></TD>

    Where $id = $rs->fields[0]

    Even with hardcoded MySQL I have never been able to resolve this delete
    per row problem. Any help would be great.

    Thanks

  • Bill Karwin

    #2
    Re: General queries

    "UKuser" <spidercc21@yah oo.co.uk> wrote in message
    news:1142285827 .226483.183150@ j33g2000cwa.goo glegroups.com.. .[color=blue]
    > I have some wierd MySQL queries. Although I am using ADODB (an
    > abstraction layer) - the queries will probably be quite general.[/color]

    Hmm. You mention ADODB, but the coding questions you are asking involve
    PHP. Also, I don't see any MySQL question in your posting. Perhaps you
    would get a more specific reply from a PHP newsgroup.
    [color=blue]
    > 1) When I post data in a url (i.e. post.php?id=120 ) and I use this
    > code: $var = secure_field($i d); it will work (on the[/color]

    What is secure_field()? Is this a function of yours?

    The expression $id is a variable. Passing the variable to the
    secure_field() function substitutes the value of $id, not the string '$id'.
    What is the value of $id? Presumably it contains the name of the request
    parameter you're reading.
    [color=blue]
    > "recieve_page.p hp"). However if I use $secure_field($ _POST['$id']) or
    > any POST/GET/REQUEST type option, it won't work.[/color]

    In PHP, putting '$id' in quotes prevents the variable from being expanded.
    So the expression is trying to find an entry in the _POST parameter array
    whose name is literally '$id', not the value of the $id variable as in the
    other example above.
    [color=blue]
    > 2) I have a table, where I want a delete button at the end of each row[/color]
    .. . .[color=blue]
    > <TD><a href='this_page .php?id=$id2'>D elete</a></TD>[/color]

    You could make the href='this_page .php?id=$id2;ac tion=delete' and then look
    for the 'action' parameter in your php script. If the value is delete, then
    delete the specified entry. If the value of the action parameter is not
    delete, then it defaults to edit.

    Regards,
    Bill K.


    Comment

    Working...