[PHP] Customize link

2011-05-05 Thread Michael Simiyu

Hello,

Here is the scenario

I have a form with the folloing fields  i. Title  ii. Category (This  
is a drop down with a list of categories which have id's - am using  
wordpress )  iii. upload file field


now what i want to do is to be able to customize a link like http://www.mysite.com/addfilecat_id=5 
 so that when i access the link it has one of the categories in the  
drop down selected..reason is i dont want users to see the  
different types of categories


So i guess my question is how to configure a meu item in a drop down  
to be automatically selected in a link...


Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Customize link

2011-05-05 Thread Daniel Brown
On Thu, May 5, 2011 at 18:10, Michael Simiyu simiyu.mich...@gmail.com wrote:

 So i guess my question is how to configure a meu item in a drop down to be
 automatically selected in a link...

?php

$cat_ids = array(1,3,5,7,13,15,24,36,81,92);

echo 'select name=categories'.PHP_EOL;
foreach ($cat_ids as $cid) {

echo '  option value='.$cid.'';

if (isset($_GET['cat_id'])  $_GET['cat_id'] == $cid) {
echo ' selected=selected';
}

echo ''.$cid.'/option'.PHP_EOL;
}
echo '/select'.PHP_EOL;

?
-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Customize link

2011-05-05 Thread admin

If your options are dynamically created you could check the value passed
against each option are mark the match with SELECTED;


Example Static:
Echo option value='5'; If(isset($_GET['cat_id'])   $_GET['cat_id'] ==
5){ echo ' SELECETED ';} echo  5/option.PHP_EOL;


Example Dynamic

for($a=1, $a = 15; $a++)
{
Echo option value='.$a.' ; If(isset($_GET['cat_id'])  $_GET['cat_id']
== $a){ echo ' SELECETED ';} echo   .$a./option.PHP_EOL;
}


Just a though



Richard L. Buskirk

-Original Message-
From: Michael Simiyu [mailto:simiyu.mich...@gmail.com] 
Sent: Thursday, May 05, 2011 6:10 PM
To: php-general@lists.php.net
Subject: [PHP] Customize link

Hello,

Here is the scenario

I have a form with the folloing fields  i. Title  ii. Category (This  
is a drop down with a list of categories which have id's - am using  
wordpress )  iii. upload file field

now what i want to do is to be able to customize a link like
http://www.mysite.com/addfilecat_id=5 
  so that when i access the link it has one of the categories in the  
drop down selected..reason is i dont want users to see the  
different types of categories

So i guess my question is how to configure a meu item in a drop down  
to be automatically selected in a link...

Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Customize link

2011-05-05 Thread Michael Simiyu

Dan,

thanks for the reply.this is the code that shows/lists the  
categories


?php
	$cats = $download_taxonomies- 
get_parent_cats();


if (!empty($cats)) {
foreach ( $cats as $c ) {
	echo 'lilabel for=category_'. 
$c-id.'input type=checkbox name=category_'.$c-id.'  
id=category_'.$c-id.' ';
		if (isset($_POST['category_'.$c-id])) echo  
'checked=checked';

echo ' / 
'.$c-id.' - '.$c-name.'/label';


// Do Children

if (!function_exists('cat_form_output_children')) {

function cat_form_output_children($child) {

global $download_taxonomies;

if ($child) {
	echo 'lilabel for=category_'.$child-id.'input  
type=checkbox name=category_'.$child-id.' id=category_'.$child- 
id.' ';
	if (isset($_POST['category_'.$child-id])) echo  
'checked=checked';

   
 echo ' / '.$child-id.' - '.$child-name.'/label';



echo 'ul class=children';
		$download_taxonomies- 
do_something_to_cat_children($child-id, 'cat_form_output_children',  
'cat_form_output_no_children');

  
  echo '/ul';


  
  echo '/li';

}

}

function cat_form_output_no_children() {

echo 'li/li';

}

}

echo 'ul 
class=children';
			$download_taxonomies-do_something_to_cat_children($c-id,  
'cat_form_output_children', 'cat_form_output_no_children');

echo 
'/ul';

echo 
'/li';
}
}
?

i can see the categories ids and i just want to get a custom link for  
each category and essentially hide this section from my memebers


Thanks


On May 6, 2011, at 1:28 AM, Daniel Brown wrote:


?php

$cat_ids = array(1,3,5,7,13,15,24,36,81,92);

echo 'select name=categories'.PHP_EOL;
foreach ($cat_ids as $cid) {

   echo '  option value='.$cid.'';

   if (isset($_GET['cat_id'])  $_GET['cat_id'] == $cid) {
   echo ' selected=selected';
   }

   echo ''.$cid.'/option'.PHP_EOL;
}
echo '/select'.PHP_EOL;

?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Customize link

2011-05-05 Thread Jim Lucas
On 5/5/2011 3:38 PM, Michael Simiyu wrote:
 Dan,
 
 thanks for the reply.this is the code that shows/lists the categories
 

you need to make the following check look at $_GET instead of $_POST.  Or, I
hate to suggest it, you can use $_REQUEST.  It includes $_GET, $_POST, and
others all in one variable.

  if (isset($_POST['category_'.$c-id])) echo 'checked=checked';

[snipped]

 
 i can see the categories ids and i just want to get a custom link for each
 category and essentially hide this section from my memebers
 
 Thanks
 
 
 On May 6, 2011, at 1:28 AM, Daniel Brown wrote:
 
 ?php

 $cat_ids = array(1,3,5,7,13,15,24,36,81,92);

 echo 'select name=categories'.PHP_EOL;
 foreach ($cat_ids as $cid) {

echo '  option value='.$cid.'';

if (isset($_GET['cat_id'])  $_GET['cat_id'] == $cid) {
echo ' selected=selected';
}

echo ''.$cid.'/option'.PHP_EOL;
 }
 echo '/select'.PHP_EOL;

 ?
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php