Jump to content
php.lv forumi

Algoritms ar do while


Pieduriens

Recommended Posts

Sveiki..

Mācību ietvaros cīnos ar vienu loģisko algoritmu..

 

http://pastebin.com/D3N38Gas

 

Vēlos iestāstīt, ka pie nosacījuma, ja šāda vērtība eksistē piekabina klāt stringam +1...

Analoģiski kā WP, kur, ja slugs eskistē, tad WP pats pielik klāt unikālu galotni...

 

Pašlaik strādā līdz trešajai reizei..

1) adrese

2) adrese-2

3) šo jau rāda tā pat: adrese-2, (vajadzētu adrese-3 utt...)

 

Ceru, ka problēmu var saprast...

Paldies...

Edited by Pieduriens
Link to comment
Share on other sites

 

$query = $CI->db->query("SELECT * FROM $table WHERE slug = '$slug'");

 

 
varētu pamēģināt

 

$query = $CI->db->query("SELECT * FROM &table WHERE slug LIKE '$slug%'");

$count = $query->num_rows();       
if ($count > 0 ) {
    $slug .= '-'.$count;
}
 return $slug;
Edited by waplet
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...