PHP - Moved: Need To Remove All '-' From Rstel Datafield In Database?!
This topic has been moved to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=317444.0 Similar TutorialsThis is probably very obvious but i gots stuck. I want to to display a list of the members then you select the member and it deletes the member. I do not get a message saying it failed, it just doesn't delete the member. Removemember.php: Code: [Select] <form action='removemember_complete.php' method='POST'> <label>Name:</label> <select name="memberid"> <?php $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sqlquery="SELECT * FROM `members` Order By name"; $result=mysql_query($sqlquery,$con); while($row=mysql_fetch_array($result)) { echo "<option value='".$row['id']."'>".$row['name']."</option>"; } ?> </select> <br> <input type="submit" value="Remove" /> </form> removemember_complete.php: Code: [Select] <?php $name=$_POST['name']; $con = mysql_connect("localhost","slay2day_User","slay2day"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slay2day_database",$con); $sql="DELETE FROM members WHERE name = '$name'"; if(mysql_query($sql,$con)) { echo 'Member Removed.<br /><a href="../index.php">Return To Points List</a><br /><a href="removemember.php">Remove More Members</a>'; } else { die('Could not submit: ' . mysql_error()); } mysql_close($con); ?> Thanks in advance. I have finaly got my removing recods page working, but i do have one problem... i have a delete button which goes to a new php page which contains the DELETE FROM, this deletes the record automaticaly. There are two paths which i could choose from the problem is i am stuck on both of them. 1. a link that will activate the delete code. 2. once the record has been deleted then it will automaticaly go back the the first page. can any one help me here please? I have written code in php to connect and insert rows into a MSSQL database. i used odbc to connect database.user can enter his details through the form. after submitting the form the details are getting stored into a database. while inserting rows into a database am not trying to insert duplicate values . for this i have given if conditions.these conditions are able to notice the user cname and name exist in the database if the same name exist. but the else part after these conditions are not working i.e rows are not getting inserted. i put everything inside the while loop. how can i correct it? This is my php code. $connect = odbc_connect('ServerDB','sa', 'pwd'); //connects database $query2="select count(*) from company";//this is needer for loop through $result2=odbc_exec($connect,$query2); while(odbc_fetch_row($result2)); { $count=odbc_result($result2,1); echo "</br>","$count"; } $query1="select * from company"; $result1 = odbc_exec($connect, $query1); # fetch the data from the database while(odbc_fetch_row($result1)) { $compar[$count] = odbc_result($result1, 1); $namearray[$count] = odbc_result($result1, 2); if($compar[$count]==$_POST['cname']) { echo "<script> alert(\"cname Exists\") </script>"; } else if($namearray[$count]==$_POST['name']) { echo "<script> alert(\"Name Exists\") </script>"; } else { $query=("INSERT INTO company(cname,name) VALUES ('$_POST[cname]','$_POST[name]') "); $result = odbc_exec($connect, $query); echo "<script> alert(\"Row Inserted\") </script>"; } } This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=328353.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=325974.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=316055.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=307587.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326002.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306153.0 This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=349934.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=356719.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=322184.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359558.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347065.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=349563.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314051.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354422.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=307639.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=356029.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=350408.0 |