cleary1981 Posted July 25, 2008 Share Posted July 25, 2008 Why does this not work? What I trying to do is if part_no already exists in part execute result 1, else execute result 2 and 3. the code doesn't seem to do anything to either table <?php if (isset($_POST['submit'])) { require "config.php"; // database connection details //convert all the posts to variables: $mod_name = $_REQUEST['mid']; $pno = $_REQUEST['part_no']; $des = $_REQUEST['description']; $price = $_REQUEST['price']; $qty = $_REQUEST['quantity']; $disc = $_REQUEST['discount']; $sup = $_REQUEST['supplier']; // if $part_no != part_no add it to part table if(mysql_num_rows(mysql_query("SELECT part_no FROM part WHERE part_no = '$pno'"))){ $result1=MYSQL_QUERY("INSERT INTO component (c_id, module_name, part_no, quantity) VALUES ('', '$mod_name', '$pno', '$qty')") or die (mysql_error()); } else { $result2=MYSQL_QUERY("INSERT INTO part (part_no, price, discount, supplier_name, description) VALUES ('$pno', '$des', '$price', '$disc', '$sup')") or die (mysql_error()); //Add new part to component list $result3=MYSQL_QUERY("INSERT INTO component (c_id, module_name, part_no, quantity) VALUES ('', '$mod_name', '$pno', '$qty')") or die (mysql_error()); } } ?> Link to comment https://forums.phpfreaks.com/topic/116594-solved-if-statement/ Share on other sites More sharing options...
MFHJoe Posted July 25, 2008 Share Posted July 25, 2008 I know this might sound like a stupid question, but are you sure $_POST['submit'] is being set? Other than that I can't see anything wrong with the rest of your code. Link to comment https://forums.phpfreaks.com/topic/116594-solved-if-statement/#findComment-599516 Share on other sites More sharing options...
cleary1981 Posted July 25, 2008 Author Share Posted July 25, 2008 lol... i changed from a from submit to a javascript function. lol Link to comment https://forums.phpfreaks.com/topic/116594-solved-if-statement/#findComment-599519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.