Ok, i have tow diffrent tables and i want to display the values for table name message that
match the value for colum BusinessName on table name business_info and message
i have two query the first one works but the second one is not dispalying values
here is my code
[code=php]
<?php
session_start();
$_SESSION[‘User_Name’];
$_SESSION[‘Password’];
$_SESSION[‘BusinessName’];
?>
<html>
<head>
<body>
<?
if ( isset($_SESSION[‘User_Name’]) && isset ($_SESSION[‘Password’]) )
{
$query = “SELECT * FROM business_info where User_Name='”.$_SESSION[‘User_Name’].”‘ AND Password='”.$_SESSION[‘Password’].”‘” ;
$result=mysql_query($query);
}
if ($result = mysql_query($query))
{
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$BusinessName= $row[‘BusinessName’];
$Keyword = $row[‘Keyword’];
$Picture1 = $row[‘Picture1’];
$Headline = $row[‘Headline’];
$Slogan =$row[‘Slogan’];
$Slogan2 = $row[‘Slogan2’];
$Description1 =$row[‘Description1’];
$Description2 = $row[‘Description2’];
$Description3= $row[‘Description3’];
$Contact2 = $row[‘Contact2’];
$Picture2 = $row[‘Picture2’];
$Picture3 = $row[‘Picture3’];
$Categories=$row[‘Categories’];
$Business_Address= $row[‘Business_Address’];
$make=$row[‘make’];
$type=$row[‘type’];
$Tel= $row[‘Tel’];
$Website=$row[‘Website’];
}
else
{
echo “<p><b>username and/or password not found. Try
again?
</b></p>”;
exit;
}
}
else
{
echo “Query failed<br />$query<br />”. mysql_error();
exit;
}
?>
<table width=”504″ border=”1″ cellpadding=”0″ cellspacing=”0″ bordercolor=”#CCCCCC”>
<tr>
<td width=”494″>
<table width=”497″ border=”0″ bgcolor=”#FFFFFF”>
<tr>
<td width=”487″>Banner</td>
</tr>
<tr>
<td background=”fondo2.jpg”>
<? echo ” Welcome <b>$BusinessName </b>”; ?>
<?
// This is the query that is not displaying any values any idea how i should fix this
if($BusinessName=$_SESSION[‘BusinessName’])
{
$sql= “SELECT * FROM messages WHERE $BusinessName='”.$_SESSION[‘BusinessName’].”‘ “;
$result=mysql_query($sql);
}
if ($result = mysql_query($query))
{
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$BusinessName= $row[‘BusinessName’];
$date = $row[‘date’];
$from = $row[‘from’];
$subject = $row[‘subject’];
$message =$row[‘message’];
}
}
?>
<tr>
<td><input type=”checkbox” name=”checkbox” value=”checkbox”></td>
<td> </td>
<td><? echo”$date”; ?></td>
<td>gg</td>
<td><? echo”$subject”; ?></td>
</tr>
?>