Search by two tables

Trying to search via two tables, this is what i have and i know the IF is wrong as you cannot do what i thought/hoped.

any help?

[php]<?php

session_start();

$conn = mysql_connect(“localhost”, “***”, “***”);
mysql_select_db("***");

//search customer_db table
$cust = $_POST [“cust_name”];
$siten = $_POST [“site_name”];
$siteid = $_POST [“site_id”];
$postc = $_POST [“post_code”];

//search job_db

$ord = $_POST [“ord_no”];
$task = $_POST [“task_name”];

$conn = mysql_connect(“localhost”, “***”, “***”);
mysql_select_db("***");

							$mysql = "";
						
						if ($cust, $siten, $siteid, $postc, $ord, $task != "")
						{
							$mysql = "SELECT * FROM customer_db, job_db WHERE = '$cust', '$siten', '$siteid', '$postc', '$ord', '$task'";
							$result = mysql_query($mysql);
							
							if (mysql_num_rows($result)==0)
							{
								echo "Sorry there are currently 0 $searchby event types currently scheduled.<br/>";
							}
							else
							{
								echo "<table width='100%' border='1'>";
								echo "<tr>";
								echo "<td>Customer Name</td>";
								echo "<td>Site Name</td>";
								echo "<td>Site ID</td>";
								echo "<td>Post Code</td>";
								echo "<td>Order Number</td>";
								echo "<td>Task Name</td>";
								echo "</tr>";
							}
							{
								while($row = mysql_fetch_array($result))
								{
								echo "<tr>";
								echo "<td>$row[cust_name]</td>";
								echo "<td>$row[site_name]</td>";
								echo "<td>$row[site_id]</td>";
								echo "<td>$row[Post_code]</td>";
								echo "<td>$row[ord_no]</td>";
								echo "<td>These are your selected results</td>";
								echo "</tr>";
								}
							}
							{
								echo "</table>";
							}
						}

mysql_close($conn);[/php]

First of all, I’ve removed the database connection information.

You seem to be connecting to the database twice - if you need to connect to different databases then you should rename your $conn variable and then use it in MySQL functions, for example:

[php]$conn_one = mysql_connect(…
mysql_select_db(‘some_db’, $conn_one);
mysql_query(‘SELECT foo FROM bar’, $conn_one);[/php]

Can you describe what you’re looking for? The jobs of a customer?

This is all resolved pal, just wanted my DB info removed.

Sponsor our Newsletter | Privacy Policy | Terms of Service