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.
| SitePoint Sponsor |
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.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
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"
}
}
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
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
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.
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.
I have tried to implode the two array inside the link like
Is this imploding fucntion done corretly?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> "; ?>
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!





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.
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.PHP Code:implode(",", $_REQUEST['frmSearch']['food_types'])





> is a special character in html, you need to use > or something else like » might be better
still the problems persists.
This is the output of the pagination even with the symbols you gave me to substitute >
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.[1] 2 '>»>
Notice: Undefined index: offerings in C:\wamp\www\nyhungry\indexpagination.php on line 553
>>
Hai!!!!





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





You canPHP Code:$params = array();
$params[] = 'something='.$somevar;
$params[] = 'anotherthing='.implode(',', $anothervar);
to see a nicely formatted array of what's in params before you use itPHP Code:echo '<pre>'; print_r($params); echo'<pre>';
right now I have the
with the implode formula they have a value of Array not the actual input value.PHP Code:[0] => food_types=Array
[1] => offerings=Array
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?
i have a question even if this is passing as array value belowPHP Code:$query = implode('&', $params);
echo "<a href=".$_SERVER['PHP_SELF'].'?'.$query.">next</a>";
will the actual value in the var_dump exist yet when $params variable used in as below?PHP Code:[0] => food_types=Array
[1] => offerings=Array
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>";





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.
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).PHP Code:[0] => food_types=Array
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
food_types should display the value entered in the form not the Array value that it display now.[0] => food_types=Array
I might be wrong.





is set to whatever this evaluates toPHP Code:$arrFoodTypes
it should do what you say? then why doesn't it???PHP Code:isset($_POST['frmSearch']['food_types'])?$_POST['frmSearch']['food_types']:array();
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
What i want is the output of print_r($arrFoodTypes); which is as below when it is set.
The output of print_r($params); will output as in the post above.ArrayArray
(
[0] => 5
)
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
i am not sure what you mean by I just only added one line of code?PHP Code:$params = array();
$params[] = 'food_types='. $arrFoodTypes;
$params[] = 'offerings='. $arrOfferings;
I should not use implode function if I am only going to use one line of code? Don't understand that bit.





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
You are concatenating it to a string. That is echo(ing) it, notice the results above?PHP Code:$string = 'something'.$array;
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!".





BTW the solution is hopefully obvious from this
Take the time to understand why.PHP Code:$var = array(1, 2, 3);
echo 'string'.$var; echo '<br>';
echo 'string'.implode(',', $var);
Awww incredible Thank you hashPHP Code:$var = array(1, 2, 3);
echo 'string'.$var; echo '<br>';
echo 'string'.implode(',', $var);
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.
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.
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