Jump to content

Problim With Serach In Result..


mo_ib_bmw

Recommended Posts

hi,yesterday i was try to do function for chek if name in database..function do :if name in database print 2if name not in database do updatebut the problime i have when modify the same name !this is print 2iam try to do some thing for this problimei successed do the function when modify the same name don't print 2 but update the infotmationbut problim again when modify the name it's don't search if the name in database or notin short i want edit this function to do :1- when modify infotmation of the same name update information only2- when modify the name search in database for the other name in database not the same name if name exists print 2 or do updatemy function

  public function chekuname($id,$uname,$upass,$uemail,$tbluser) {   $sql3=mysql_query("select uname from $tbluser where id='$id'");	$rows3=mysql_fetch_array($sql3);	$newuname=$rows3['uname'];   $row3=mysql_num_rows($sql3); if($row3 == 1){if ($uname == $newuname) {  $u_sql=@mysql_query("update mosta5dm set uname='$uname',upass='$upass',uemail='$uemail' where id='$id'");  if(u_sql) {   echo "updated";   exit();  } else {   echo "not update";   exit(); } } else {$sql4=mysql_query("select uname from $tbluser");while($row44=mysql_fetch_array($sql4)) {if ($row44['uname'] == $uname){echo 1;}else {echo 2;}  }  }  } else { echo "not found"; }  }

Link to comment
Share on other sites

Just add a WHERE condition to this query:$sql4=mysql_query("select uname from $tbluser");e.g. WHERE uname='$uname'. That will tell you if the name already exists, and you can either update or not. That will be better than getting all rows and looping through them. You also have an error here: $u_sql=@mysql_query("update mosta5dm set uname='$uname',upass='$upass',uemail='$uemail' where id='$id'"); if(u_sql)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...