ZenphotoCMS Forum
Tag Management - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Plugins (https://forum.zenphoto.org/forum-6.html)
+--- Thread: Tag Management (/thread-7558.html)

Pages: 1 2


Tag Management - Sabyre - 2010-09-02

OK, cool... So I can do...

$tags = $_POST['tags']; $newtag = explode(",", $tags); foreach($newtag){
for the comma seperated tags.

and....

if (strcasecmp($newtag, $row['name']) == 0) {
for the case insensitive comparison?




Tag Management - acrylian - 2010-09-02

foreach($newtag as $something) { of course.

I think it might be better to use strtolower() before checking as you otherwise might accidentally store double ones in the database later as you have still the value with the case difference.




Tag Management - kagutsuchi - 2010-09-02

Good point; I didn't think of that. Whether it's faster to use strtolower() or strcasecmp() + array_unique(), I'm not sure, but strtolower() is probably easier.




Tag Management - sbillard - 2010-09-02

Also you might wish to have code that will deal with user input strings that might wish to include commas in their tag. (Or you could just tell them that is not allowed.)




Tag Management - acrylian - 2010-09-02

I think normally tags are used as "keywords" and rarely include a comma. Of course a more rarely used ; could be used as a delimiter as well or a |.




Tag Management - Sabyre - 2010-09-02

foreach($newtag as $something)
Does that mean I have to reference $newtag as $something anywhere else in the loop? Does it change the variable?

Would it be better to use

while($newtag = >0) {




Tag Management - sbillard - 2010-09-02

You probalby need to review your PHP syntax. http://www.php.net/manual/en/control-structures.foreach.php




Tag Management - acrylian - 2010-09-03

Also I get a little the impression that you should learn a few more php basics before proceeding. This forum is of course not for learning these...




Tag Management - Sabyre - 2010-09-09

Understood, I know enough php/mysql to get me in trouble and I have enough tenacity to get what I want. I work at something and learn as I go until it has the desired effect.

I created this on my own and it works fabulously:

`




Tag Management - Sabyre - 2010-09-09

oops, for my purposes i will need to write something that checks if the folder exists....




Tag Management - Sabyre - 2010-09-09

Got it...

added:
`
$sqlalbumid = mysql_query("SELECT id, folder FROM zp_albums WHERE folder ='" . $album . "'");
$albumid = mysql_fetch_array( $sqlalbumid );
if (strcasecmp($album, $albumid['folder']) 0) {
echo "Album folder " .$album. " does NOT exist, please check the spelling.";
}

else {
`




Tag Management - kagutsuchi - 2010-09-10

Two notes:

The code you posted is not secure. You really should be sanitizing anything that comes through $_POST. It's probably also not safe against XSRF attacks, though I'm not too familiar with that subject.

I see a lot of mysql_query() in your code; it's probably better to compile one long query in your code and then, at the end, actually query the database. (I don't really have experience with databases, but I'm speaking from a coding standpoint.)