Jump to content
php.lv forumi

Ļoti līdzīgi skripti, bet tikai vienā ir kļūda


daGrevis

Recommended Posts

Sveiki,

 

Divi līdzīgi skripti.

 

1) http://paste.php.lv/d34c00d06ca94ece9cca2d8a7029a39e?lang=php (bez kļūdas);

2) http://paste.php.lv/a970e692c2995682cacf8de7de5fb27e?lang=php (ar kļūdu).

 

 

Pirms tam tiek iekļautas visas minētās funkcijas, attiecīgās funkcijas, kas varētu interesēt:

 

function get__level( $id )
{

$query = mysql_query("

	SELECT `level`
	FROM `users`
	WHERE `id` = '{$id}'
	LIMIT 1

") or exit( mysql_error() );

$result = mysql_result( $query, 0 );


return $result;

}

function format__level( $user_id )
{

switch( get__level( $user_id ) ) {

	case 1:

		return '<span style="color: black;">' . get__username( $user_id ) . '</span>';

	case 2:

		return '<span style="color: #cc6600;"><strong>' . get__username( $user_id ) . '</strong></span>';

	case 3:

		return '<span style="color: #009900;"><strong>' . get__username( $user_id ) . '</strong></span>';

	case 4:

		return '<span style="color: #800000;"><strong>' . get__username( $user_id ) . '</strong></span>';

}

}

Link to comment
Share on other sites

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...