roxiroxi Posted December 13, 2006 Share Posted December 13, 2006 hi,I've got a problem here, can anyone help me?$hostName = "localhost";$userName = "root";$password = "password";$dbName = "dvdswap";$title = $_POST['title'];$option = $_POST['option']; // make connection to databasemysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");mysql_select_db($dbName) or die( "Unable to select database $dbName");if ($_POST['option'] == "exactly") { $query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title = '$title'";} else ($_POST['option'] == "starts") { $query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title like '$title%'";} else ($_POST['option'] == "includes") { $query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title like '%$title%'";} Link to comment https://forums.phpfreaks.com/topic/30488-php-help-if/ Share on other sites More sharing options...
Cagecrawler Posted December 13, 2006 Share Posted December 13, 2006 Whats the problem? Link to comment https://forums.phpfreaks.com/topic/30488-php-help-if/#findComment-140354 Share on other sites More sharing options...
roxiroxi Posted December 13, 2006 Author Share Posted December 13, 2006 the problem is that i get a white page, i know the error is there coz when i dont use the if statements, with one sql query, i get the info Link to comment https://forums.phpfreaks.com/topic/30488-php-help-if/#findComment-140355 Share on other sites More sharing options...
Cagecrawler Posted December 13, 2006 Share Posted December 13, 2006 Couple of things:echo $_POST['option'] to see what you get.If you get the right thing, try this switch code instead of the ifs.:[code]switch ($_POST['option']){case "exactly":$query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title = '$title'";break;case "starts":$query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title like '$title%'";break;case "includes":$query = "SELECT product.prodid, product.title, product.pyear, product.format, product.cert, product.userid FROM product where product.title like '%$title%'";break;}[/code] Link to comment https://forums.phpfreaks.com/topic/30488-php-help-if/#findComment-140360 Share on other sites More sharing options...
roxiroxi Posted December 13, 2006 Author Share Posted December 13, 2006 Thank you for everything it is working! Link to comment https://forums.phpfreaks.com/topic/30488-php-help-if/#findComment-140459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.