i actually trying to run 2 select queries and get user id from members3 table and productid, title,price, categoryname and img from product4 tables. i quite noob in php so not too sure whats went wrong. there is no error msg show just that my database data only have userid and productid with 0 value the rest are null...
need advice from u guys.. thanks
<?
$objConnect = mysql_connect("localhost","xxx","xxxx") or die(mysql_error());
$objDB = mysql_select_db("db-test");
$id=$_GET['id'];
$email = $_SESSION['email'];
$sql="SELECT userid FROM members3 where email='$email'";
$result2=mysql_query($sql);
$objQuery2 = mysql_query($sql) or die ("Error Query [".$sql."]");
//while($objResult2 = mysql_fetch_array($objQuery2))
//{
//$userid =$objResult["userid"];
//}
$strSQL = "SELECT * FROM products4 where productid='$id'";
$result=mysql_query($strSQL);
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery) && $objResult2 = mysql_fetch_array($objQuery2))
{
$userid =$objResult["userid"];
$p = $objResult["productid"];
$t = $objResult["title"];
$price = $objResult["price"];
$cat = $objResult["categoryname"];
$img = $objResult["img"];
$action ='';
if(isset($_GET['action']) ) {
$action = $_GET['action'];
}
switch ($action) {
case 'addtowishlist':
$con = mysql_connect("localhost", "root", "boon84");
$db = mysql_select_db ("db-test", $con) or die ("Could not select database");
$query = mysql_query("INSERT INTO wishlist(userid,productid,title,price,categoryname,img) VALUES( '$userid', '$p', '$t', '$price', '$cat', '$img')") or die(mysql_error());
}
}
?>