Friday 15 February 2013

html - PHP Condition Total records -


I am developing a simple situation where I would like to show an HTML code, if only the total number of rows from a record set is The HTML content is not appearing more than 1 , what could be the best bet option?

  mysql_select_db ($ database_connection, $ connection); $ Query_user = sprintf ("Choose from users WHERE id =% s", GetSQLValueString ($ colname_user, "int")); $ User = mysql_query ($ query_user, $ connection) or die (mysql_error ()); $ Row_user = mysql_fetch_assoc ($ user); $ Total Rows_user = mysql_num_rows ($ user); & Lt ;? Php if ($ totalRows_user> 1) {? & Gt; & Lt; A href = "excluiru.php? Id = & lt ;? php echo $ row_user ['id'] ;; & gt; & Gt; & Lt; Img src = "imagens / delete.png" alt = "remover" onClick = "Confirm Return ('Do you really want to delete this user?');" / & Gt; & Lt; / A & gt; Delete user & lt ;? Php}? & Gt;   

Update: I find that mysql_num_rows ($ user); giving value to zero all the time is there any other way to count?

I found and resolved the problem: D

  & lt; Php $ isExist = mysql_query ("Select COUNT (ID) from users"); $ R = mysql_fetch_array ($ is eXIST); If ($ r ['COUNT (id)']> 1) {? & Gt;   

I should not use the total amount but fetch_array

Or

  if ($ totalRows_user> = 1)    

No comments:

Post a Comment