php-general Digest 6 May 2011 13:01:43 -0000 Issue 7300
Topics (messages 312693 through 312704):
Customize link
312693 by: Michael Simiyu
312694 by: Daniel Brown
312695 by: admin.buskirkgraphics.com
312696 by: Michael Simiyu
312697 by: Jim Lucas
Re: php-general Digest 5 May 2011 21:55:09 -0000 Issue 7299
312698 by: e-letter
312703 by: David Robley
Upload size limit stays at 8MB
312699 by: James Moe
312700 by: Ross Hansen
Parsing a simple sql string in php
312701 by: Ashley Sheridan
312702 by: Stuart Dallas
312704 by: Ken Guest
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
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/addfile&cat_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
--- End Message ---
--- Begin Message ---
On Thu, May 5, 2011 at 18:10, Michael Simiyu <[email protected]> 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/
--- End Message ---
--- Begin Message ---
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:[email protected]]
Sent: Thursday, May 05, 2011 6:10 PM
To: [email protected]
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/addfile&cat_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
--- End Message ---
--- Begin Message ---
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 '<li><label 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 '<li><label 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;
?>
--- End Message ---
--- Begin Message ---
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;
>>
>> ?>
>
>
--- End Message ---
--- Begin Message ---
Readers,
Looking through the mail lists archives, only the following message
seems to advise about the possibility to use gnuplot:
http://marc.info/?l=php-general&m=96248542218029&w=2
Is it possible to start gnuplot using php, to plot a graph from
postgresql data. For example, a table is created in the required
gnuplot data file format so the command for gnuplot would be something
like:
plot <"SELECT * FROM gnuplotdatatable;"
But can't see a php command to start gnuplot in the first step. Any help please?
--- End Message ---
--- Begin Message ---
e-letter wrote:
> Readers,
>
> Looking through the mail lists archives, only the following message
> seems to advise about the possibility to use gnuplot:
> http://marc.info/?l=php-general&m=96248542218029&w=2
>
> Is it possible to start gnuplot using php, to plot a graph from
> postgresql data. For example, a table is created in the required
> gnuplot data file format so the command for gnuplot would be something
> like:
>
> plot <"SELECT * FROM gnuplotdatatable;"
>
> But can't see a php command to start gnuplot in the first step. Any help
> please?
You might find jpgraph useful.
Cheers
--
David Robley
Pizza IS the four food groups!
Today is Sweetmorn, the 53rd day of Discord in the YOLD 3177.
--- End Message ---
--- Begin Message ---
Hello,
apache v2.2.15 (Linux/SUSE)
php v5.3.3
linux v2.6.34.7-0.7-desktop #1 SMP
I updated </etc/php5/apache2/php.ini> to change
upload_max_filesize = 2M
to
upload_max_filesize = 60M.
php_info() shows the changed value; "echo
ini_get(upload_max_filesize)" shows the changed value. Yet when I
attempt an upload, I get this in the error log:
PHP Warning: POST Content-Length of 39246714 bytes exceeds the limit of
8388608 bytes in Unknown on line 0, referer: http://www.sma.com/sma/upload/
Hmm. "Unknown on line 0"? A bit vague.
8MB max seems a bit less than the 60MB listed.
Where else could PHP be getting settings info?
--- End Message ---
--- Begin Message ---
Hey,
There is also an option for post_max_size = xM
x being the number specified.
This should be located in your php.ini file somewhere. check to make sure that
this is set high enough else it could also be causing the issue.
> To: [email protected]
> Date: Thu, 5 May 2011 21:51:26 -0700
> From: [email protected]
> Subject: [PHP] Upload size limit stays at 8MB
>
> Hello,
> apache v2.2.15 (Linux/SUSE)
> php v5.3.3
> linux v2.6.34.7-0.7-desktop #1 SMP
>
> I updated </etc/php5/apache2/php.ini> to change
> upload_max_filesize = 2M
> to
> upload_max_filesize = 60M.
> php_info() shows the changed value; "echo
> ini_get(upload_max_filesize)" shows the changed value. Yet when I
> attempt an upload, I get this in the error log:
>
> PHP Warning: POST Content-Length of 39246714 bytes exceeds the limit of
> 8388608 bytes in Unknown on line 0, referer: http://www.sma.com/sma/upload/
>
> Hmm. "Unknown on line 0"? A bit vague.
> 8MB max seems a bit less than the 60MB listed.
> Where else could PHP be getting settings info?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hiya, has anyone had any experience with parsing a string of sql to break it
down into its component parts? At the moment I'm using several regex's to parse
a string, which works, but I'm sure there's a more elegant solution.
The general idea is to produce a nice looking page giving details of updated
fields and values.
I'm only concerned with update statements really, and the queries are very
simple, operating on one table at a time, with no sub queries or selects.
Thanks in advance if anyone is able to suggest anything!
Thanks
Ash
--- End Message ---
--- Begin Message ---
On Friday, 6 May 2011 at 10:05, Ashley Sheridan wrote:
Hiya, has anyone had any experience with parsing a string of sql to break it
down into its component parts? At the moment I'm using several regex's to parse
a string, which works, but I'm sure there's a more elegant solution.
>
> The general idea is to produce a nice looking page giving details of updated
> fields and values.
>
> I'm only concerned with update statements really, and the queries are very
> simple, operating on one table at a time, with no sub queries or selects.
>
> Thanks in advance if anyone is able to suggest anything!
I don't have any experience doing it with SQL, but I have written several
parsers in my time, and I'd strongly recommend against using regexes to do it.
The usual way to approach this problem is to tokenise the input, then take each
token at a time and branch where there are several options for what comes next.
As you go along, build up a data structure that represents the data you need.
Alternatively you could ask Google...
http://www.phpclasses.org/package/4916-PHP-Build-a-tree-to-represent-an-SQL-query.html
http://code.google.com/p/php-sqlparser/
and more: http://jmp.li/fmy
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
On Fri, May 6, 2011 at 10:05 AM, Ashley Sheridan
<[email protected]> wrote:
> Hiya, has anyone had any experience with parsing a string of sql to break it
> down into its component parts? At the moment I'm using several regex's to
> parse a string, which works, but I'm sure there's a more elegant solution.
>
> The general idea is to produce a nice looking page giving details of updated
> fields and values.
>
> I'm only concerned with update statements really, and the queries are very
> simple, operating on one table at a time, with no sub queries or selects.
>
> Thanks in advance if anyone is able to suggest anything!
I'd suggest at least taking a look at pear's sql parser package -
using it might save you some headaches ;)
http://pear.php.net/package/SQL_Parser
> Thanks
> Ash
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://blogs.linux.ie/kenguest/
--- End Message ---