SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 51
  1. #26
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,411
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    It looks like there's no such thing as a $_REQUEST['frmSearch'], so maybe you should try

    $_REQUEST['food_types'][0]

    and

    $_REQUEST['offerings'][0]

    instead.
    Although 'offerings' doesn't seem to be an array, it's empty.

  2. #27
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look at it now it is an array. It just going crazy and heated right now.

    I have taken out the ["frmsearch"] but still it will display some undifined messages!

    that's the var_dump below.
    array(6) {
    ["name"]=>
    string(0) ""
    ["zipcode"]=>
    string(5) "10468"
    ["state"]=>
    string(0) ""
    ["frmSearch"]=>
    array(2) {
    ["food_types"]=>
    array(1) {
    [0]=>
    string(1) "5"
    }
    ["offerings"]=>
    array(1) {
    [0]=>
    string(1) "5"
    }
    }

  3. #28
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,411
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    But now 'frmSearch' is there.
    It seems that you send different things in different occasions. You have two choices:
    1) always send the same variables
    2) manage the different scenarios

  4. #29
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thing is that offering will only appear if it is set onlye as a difference from the other input of the form.

    offering is a checkbox input field.

  5. #30
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean two choices with this kind of form?

    how would be always sending the same variable?

    It sound like the second option if what I am loooking for manage the different scenarios where user will be free to enter what they want. The form works alright the issues comes when passing the variables of the form through the pagination script.

  6. #31
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried to implode the two array inside the link like

    Code:
    <?php 
          echo  "<a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&name=". $_REQUEST['name']. '&zipcode=' . $_REQUEST['zipcode'] .'&state=' . $_REQUEST['state'] . 
    	  implode('&food_types= ','&offering' array($_REQUEST['frmSearch']['food_types'] $_REQUEST['frmSearch']['offerings'])"'><</a> ";
    ?>
    Is this imploding fucntion done corretly?

    the above is a pagination link that will retrieve five indexes and two of them are arrays. as I said I have put the two array inside the implode function and the rest outside.


    Help!

  7. #32
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by co.ador View Post
    Is this imploding fucntion done corretly?
    Are you seriously asking that? I mean did you even try? or just start typing here instead of your code editor?

  8. #33
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried the follows but it's not activating the >> as a link. I think somewhere in between <a the script inside the <a open and the symbol > then it get lost the effect of activating the link.

    PHP Code:
    echo "<a href='{$_SERVER['PHP_SELF']}?currentpage={$nextpage}&name={$_POST['name']}&zipcode={$_POST['zipcode']}&state={$_POST['state']}&food_types=".(is_array($_REQUEST['frmSearch']['food_types'])) ? implode(","$_REQUEST['frmSearch']['food_types']) : ""."&offerings=".(is_array($_REQUEST['frmSearch']['offerings'])) ? implode(","$_REQUEST['frmSearch']['offerings']) : ""."'>>></a>"

    again the >> is not display as a link rather as a plain text with the script above.

  9. #34
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    implode(","$_REQUEST['frmSearch']['food_types']) 
    the implode here will separate the variables array and its $_REQUEST value from the other variables, if the test results as true else : false. But some how the link is not being activated and it is not displaying any error it just that the >> won't link.

  10. #35
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > is a special character in html, you need to use &gt; or something else like &raquo; might be better

  11. #36
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still the problems persists.

    This is the output of the pagination even with the symbols you gave me to substitute >


    [1] 2 '>>
    Notice: Undefined index: offerings in C:\wamp\www\nyhungry\indexpagination.php on line 553
    >>
    you see >> it won't link and if you notice in [1] 2 '>> the apostrophe ' is part of the closing in the php script inside the <a> tags won't will appear as plain text. I don't see any missing tags or any missing parse characters in there.

    Hai!!!!

  12. #37
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you have a difficult problem, simplify it. Why don't you do this one variable at a time and see where the problems are.

    Here is a start point:
    PHP Code:
    $params = array();
    $query implode('&'$params);
    echo 
    '<a href=".$_SERVER['PHP_SELF'].'?'.$query.'">next</a>'; 
    There is a typo in that, but see how easy it is to spot with syntax highlighting, and a small amount of code.

  13. #38
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have seem the typo thank you. The text next links good.

    Now I am trying to fill the array like

    PHP Code:
    $params = array('food_types=' $_REQUEST['frmSearch']['food_types'] . offerings=' .$_REQUEST['frmSearch']['offerings']); 

    tried like that didn't work. Don't know weather I should include the variable 'food_types' and 'offerings' inside the array.

  14. #39
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or instead assign it in the implode function!


    PHP Code:
    $params = array($_REQUEST['frmSearch']['offerings']);
    $query implode('&offerings='$params);
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>"

  15. #40
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $params = array();
    $params[] = 'something='.$somevar
    $params[] = 'anotherthing='.implode(','$anothervar); 
    You can
    PHP Code:
    echo '<pre>'print_r($params); echo'<pre>'
    to see a nicely formatted array of what's in params before you use it

  16. #41
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right now I have the
    PHP Code:
    [0] => food_types=Array
        [
    1] => offerings=Array 
    with the implode formula they have a value of Array not the actual input value.


    i just concern of the value it is bring it out, instead shouldn't be them empty if they are coming as not set input or even display the values if they are set. Above the food_types and offerings variables were set and they came out as Array values.

    Well this is the var_dump of the results above I can see the what is printing is the array type instead of the values.

    ["frmSearch"]=>
    array(2) {
    ["food_types"]=>
    array(1) {
    [0]=>
    string(1) "5"
    }
    ["offerings"]=>
    array(1) {
    [0]=>
    string(1) "5"
    }
    }


    Now the rest of the code you gave me above will be use below as right?

    PHP Code:
    $query implode('&'$params);
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>"
    i have a question even if this is passing as array value below

    PHP Code:
    [0] => food_types=Array
        [
    1] => offerings=Array 
    will the actual value in the var_dump exist yet when $params variable used in as below?

    PHP Code:
    $query implode('&'$params);
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>"

    thank you.


    The whole code would look like.

    PHP Code:
        $params = array();
    $params[] = 'food_types='$arrFoodTypes
    $params[] = 'offerings='$arrOfferings
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$params.">next</a>";
    query implode('&'$params);
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>"

  17. #42
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by co.ador View Post
    The whole code would look like.
    Quote Originally Posted by hash View Post
    When you have a difficult problem, simplify it. Why don't you do this one variable at a time and see where the problems are.
    Forget the whole code, get it working one bit at a time. Add a variable/array/whatever to params, print $query, check the link, print_r $params, look for parse errors or warnings, fix, then move to the next one.

    PHP Code:
    [0] => food_types=Array 
    is that what you expect? if not, why not? and what do you think will happen when you implode that? (hint imploding is concatenating strings).

  18. #43
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    set in the form to a value=x

    Then it is recieved in page2.php like

    PHP Code:
     $arrFoodTypes = isset($_POST['frmSearch']['food_types'])?$_POST['frmSearch']['food_types']:array();
        
    $arrOfferings = isset($_POST['frmSearch']['offerings'])?$_POST['frmSearch']['offerings']:array(); 

    therefore

    [0] => food_types=Array
    food_types should display the value entered in the form not the Array value that it display now.

    I might be wrong.

  19. #44
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $arrFoodTypes 
    is set to whatever this evaluates to

    PHP Code:
    isset($_POST['frmSearch']['food_types'])?$_POST['frmSearch']['food_types']:array(); 
    it should do what you say? then why doesn't it???

    PHP Code:
    $params = array();
    $params[] = 'food_types='$arrFoodTypes
    query implode('&'$params);
    echo 
    "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>"

    // debugging
    print_r($params); // is this what you want? no? you only added one line of code, so that line is the one causing problems.
    echo $arrFoodTypes;
    print_r($arrFoodTypes);
    //hmm 

  20. #45
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What i want is the output of print_r($arrFoodTypes); which is as below when it is set.

    ArrayArray
    (
    [0] => 5
    )
    The output of print_r($params); will output as in the post above.

    Well the problems laids down in there. I don't see anything wrong since I am assigning the variable 'food_types=' a value which is $arrFoodTypes and it is being set. but still it will output [0] => food_types=Array

    PHP Code:
     $params = array();
    $params[] = 'food_types='$arrFoodTypes
    $params[] = 'offerings='$arrOfferings
    i am not sure what you mean by I just only added one line of code?
    I should not use implode function if I am only going to use one line of code? Don't understand that bit.

  21. #46
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you ignore the arrofferings line, then you just added one line of code to something that was working. So if results aren't what you expected then you have a very narrow scope to look for problems - specifically with that one line (it might turn out the problem is before that line, but then it is one variable to trace back).

    You aren't assigning $array to a variable when you do this
    PHP Code:
    $string 'something'.$array
    You are concatenating it to a string. That is echo(ing) it, notice the results above?

    You need to learn about types, strings, arrays etc. I've tried to show you an approach that can help isolate problems, but you need to be able to solve those problems. Or at least have them simple enough that you can post here with "why does echoing an array not print_r an array" or whatever it is - instead of "my code is broken in multiple places, help!".

  22. #47
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW the solution is hopefully obvious from this
    PHP Code:
    $var = array(123);
    echo 
    'string'.$var; echo '<br>';
    echo 
    'string'.implode(','$var); 
    Take the time to understand why.

  23. #48
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $var = array(123);
    echo 
    'string'.$var; echo '<br>';
    echo 
    'string'.implode(','$var); 
    Awww incredible Thank you hash

    I can see the problem now echoing without implode just give you the type but implode give you the values of that type...

    Now I understand that, I see the comman separating the values.That just one part of what I imaging I am looking for. I think I am not even clear of how to structure what I want in between. the separator, the values, and the assigned variable that will hold the values inside.

    For instance:

    After a little analysis I have though that instead of putting a 1,2,3 numbers inside of the array function as values then create a dynamical array where the values are going to be generated according to the users input.

    PHP Code:
     $var = array($_POST['frmSearch']['types'], if !isset($_POST['frmSearch']['offers']){""}else{echo $_POST['frmSearch']['offers]; })
    echo '
    string'.$var; echo '<br>';
    echo '
    string='.implode(',', $var); 

    The first line is throwing a parse error don't know why. But that would be the next step to generate those values inside the array dynamically.

  24. #49
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I honestly don't know where to start with tha code sample you've provided. There are some fundamental things you need to grasp co.ador.

    I'd fix it co.ador, honestly I would, but even now you don't seem to be grasping any of this.

    Take few steps back, start simpler and work up to where you want/need to be, you'll feel much better for it.

    Promise.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  25. #50
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should consider getting a php book that's meant for beginners. You have a lot of holes in your knowledge of the basics, and it's causing you a lot of trouble. You're trying to run before you can walk.

    I find it really difficult to help you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •