のは文字列がすでに存在するかどうかを確認し、最後に+1を追加する方法はありますか?
$strig = "red-hot-chili-peppers-californication";
はすでに私のデータベースに存在する場合、私がチェックしましょう:
$query = dbquery("SELECT * FROM `videos` WHERE `slug` = '".$strig."';");
$checkvideo = dbrows($query);
if($checkvideo == 1){
// the code to be executed to rename $strig
// to "red-hot-chili-peppers-californication-2"
// it would be great to work even if $string is defined as
// "red-hot-chili-peppers-californication-2" and
// rename $string to "red-hot-chili-peppers-californication-3" and so on...
}
は、私はもっとフレンドリーURL構造のためのユニークなナメクジを作成するために、これをやりたいです。
ありがとうございました。
ここで 'dbrows($ query)'とは何ですか? –
これはちょうどmysql_num_rows関数です – m3tsys