forms and things

[b][red]This message was edited by pdunn at 2006-10-31 11:10:0[/red][/b][hr]
hello all,

I have a form and part of it is before some code because the latter part of the form uses variables defined in the code that is sandwiched by the form. The manner inwhich I use the form in outside of the 'php' tags
<?php ... ?> [html tags].

this is part of the code


...

<?php
...

//REMOVE ME<br /> PART A
echo " the accepts that are being passed over to the sorting operation is ";
print_r($accept);
echo "";


?>
//PART B
" name="accept" />
" name="reject" />


<?php

//REMOVE ME PART C
echo " the accepts are ";
print_r($accept);
echo "";
} //ends the if statement

if (isset($_POST['sort']))
{
if (isset($_POST['accept']))
{
$accept = $_POST['accept'];
//ReMOVE ME PART D
echo "Hellos, I am set and the accepts have the value of ";
print_r($accept);

...


I don't know how to used code tags or whatever, but that's my code.

In PART A, the values are correct.
In PART B, I HOPE the values are correct, but I don't know.
In PART C, the values are correct.
In PART D, the values are wrong and I get the value of "Array".

Does anyone knows what could be wrong?

Thank you,

pdunn


Comments

  • this line (and the other one for $accept):
    [code]
    " name="reject" />
    [/code]
    does nothing as you should be printing the variable for it to get to be outputted as HTML. but if the variables are arrays then it will not work, but you can convert the array to a string using implode() then printing it like this:
    [code]
    " name="reject" />
    [/code]

    then you use explode() to convert the string back to an array

    ------
    nugent



  • Thank you nugent,

    So I would have to convert an array to a string first, then once passed, I convert back to an array? That is my understanding.

    Also, I am not attempting to print the values as the input is hidden. Do I need to use "print()" just to pass a string. I know I passed strings before, but I never did inbetween php code like this before.

    Thank you for any clarifications.




    : this line (and the other one for $accept):
    : [code]
    : " name="reject" />
    : [/code]
    : does nothing as you should be printing the variable for it to get to be outputted as HTML. but if the variables are arrays then it will not work, but you can convert the array to a string using implode() then printing it like this:
    : [code]
    : " name="reject" />
    : [/code]
    :
    : then you use explode() to convert the string back to an array
    :
    : ------
    : nugent
    :
    :
    :
    :


  • : So I would have to convert an array to a string first, then once passed, I convert back to an array? That is my understanding.
    :

    yeah as far as i know you cannot pass an array about in this fashion, but you can do it with strings / numbers

    : Also, I am not attempting to print the values as the input is hidden. Do I need to use "print()" just to pass a string. I know I passed strings before, but I never did inbetween php code like this before.

    because the variables are being passed from server to client back to server using a hidden you have to print() or echo() so the values will be sent to the client

    but if you do print() it and look at the source code you will see the value in the html such as



    ------
    nugent



  • [b][red]This message was edited by pdunn at 2006-11-3 8:45:47[/red][/b][hr]
    One small tiny little itsy problem, my array is a multidimensional array. It is an array of arrays. Sorry I did not mention this before. Now I am thinking about looping through the outer array imploding the inners, seperating them by ' # ', then I will find the #, concate excluding the #, then explode and array_push(). Is that a run-on? Does anyone know a better way to do this?

    Thank you

    .....


    Sorry but this will still not work given that the values in the array could be
    A[0] => home.php
    A[1] => 2006-01-01
    A[2] => this is information in the array
    A[3] => this is some more words

    when imploded with my method it becomes


    how would I know how to put the strings back in the 2nd and 3rd positions?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories