Jump to content

Value repatition


franknu

Recommended Posts

Ok i am tryin to get a value to display from my database my problem is that it is repeating like 20 times when i only have one row that match that value but then same value keep displaying like 20 times please help

 


<?

$sql=" SELECT   messages.* FROM business_info,messages
WHERE business_info.BusinessName=messages.BusinessName";
$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
     
      $date = $row['date'];
      $from =  $row['from'];
  $status = $row['status'];
      $subject = $row['subject'];
      $message =$row['message'];

				echo"<tr>";
                      echo" <td>";   
				  echo' <input type="checkbox" name="checkbox" value="checkbox"></td>';
                       echo" <td> $date </td>";
                       echo" <td> $from </td> ";
                        echo"<td> $status </td>";
                        echo"<td><a href='message_display'> $subject </a></td>";
                     echo"</tr>";


				  }
				  ?>

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/
Share on other sites

Ok i am tryin to get a value to display from my database my problem is that it is repeating like 20 times when i only have one row that match that value but then same value keep displaying like 20 times please help

 


<?

$sql=" SELECT   messages.* FROM business_info,messages
WHERE business_info.BusinessName=messages.BusinessName";
$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
     
      $date = $row['date'];
      $from =  $row['from'];
  $status = $row['status'];
      $subject = $row['subject'];
      $message =$row['message'];

				echo"<tr>";
                      echo" <td>";   
				  echo' <input type="checkbox" name="checkbox" value="checkbox"></td>';
                       echo" <td> $date </td>";
                       echo" <td> $from </td> ";
                        echo"<td> $status </td>";
                        echo"<td><a href='message_display'> $subject </a></td>";
                     echo"</tr>";


				  }
				  ?>

 

 

I think that was the code I have answered yesterday!!

any way heres what you should do maybe the joining isnt right or if its right put conditon to limit it I remember yesterday theres a condition on that query like puting this

messages.BusinessName= 'your condition

'

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278900
Share on other sites

ok, i fixed the error but i am displaying the same values 27 times then another that match but and repeats another 27 times

 

$sql="SELECT   messages.* FROM business_info,messages
WHERE business_info.BusinessName=messages.BusinessName";


$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
     
      $date = $row['date'];
      $from =  $row['from'];
  $status = $row['status'];
      $subject = $row['subject'];
      $message =$row['message'];

				echo"<tr>";
                      echo" <td>";   
				  echo' <input type="checkbox" name="checkbox" value="checkbox"></td>';
                       echo" <td> $date </td>";
                       echo" <td> $from </td> ";
                        echo"<td> $status </td>";
                        echo"<td><a href='message_display'> $subject </a></td>";
                     echo"</tr>";


				  }
				  ?>

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278994
Share on other sites

add another condition

SELECT  messages.* FROM business_info,messages

WHERE business_info.BusinessName=messages.BusinessName and messages.BusinessName='condition'

 

i dont understand do you have the errors out of these

ok  maybe your are getting data from bussines not from message

 

try this

SELECT  business_info.* FROM business_info,messages

WHERE business_info.BusinessName=messages.BusinessName";

 

if not

 

SELECT  x.date, x.from etch FROM business_info y

INNER JOIN messages x ON y.BusinessName=x.BusinessName

where// if you have the conditions. the limiting condition you want  any if that limit issue

 

or if you want dont use the alias if that will cause you head ache

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279007
Share on other sites

now i am getting something with more sense,

 

I am displaying 3 rows which it is what i have but not values and this is what i have

 


$sql="SELECT   business_info.* FROM business_info,messages
WHERE business_info.BusinessName=messages.BusinessName and messages.BusinessName='".$_SESSION['BusinessName']."' ";

$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
     
      $date = $row['date'];
      $from =  $row['from'];
  $status = $row['status'];
      $subject = $row['subject'];
      $message =$row['message'];

				echo"<tr>";
                      echo" <td>";   
				  echo' <input type="checkbox" name="checkbox" value="checkbox"></td>';
                       echo" <td> $date </td>";
                       echo" <td> $from </td> ";
                        echo"<td> $status </td>";
                        echo"<td><a href='message_display'> $subject </a></td>";
                     echo"</tr>";


				  }
				  ?>

 

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279015
Share on other sites

ok, i want to select values from the colum name BusinessName, date from, subject and message  from database named messages that are equal to $_SESSION['BusinessName']." basicly,

 

here is my error message

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in

 

and here is my code that is driving nut


$sql="SELECT  * FROM messages
WHERE BusinessName='".$_SESSION['BusinessName']." ";

$result=mysql_query($sql);

while($row=mysql_fetch_assoc($result))
{
     
      $date = $row['date'];
      $from =  $row['from'];
  $status = $row['status'];
      $subject = $row['subject'];
      $message =$row['message'];

                   echo"<tr>";
                       echo" <td>";   
				   echo' <input type="checkbox" name="checkbox" value="checkbox"></td>';
                       echo" <td> $date </td>";
                        echo" <td> $from </td> ";
                        echo"<td> $status </td>";
                        echo"<td><a href='message_display'> $subject </a></td>";
                     echo"</tr>";


				  }
				  ?>

 

Link to comment
https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279045
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.