franknu Posted June 20, 2007 Share Posted June 20, 2007 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/ Share on other sites More sharing options...
The Little Guy Posted June 20, 2007 Share Posted June 20, 2007 If you have PHP myAdmin, did you run the query through it? Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278898 Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 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 ' Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278900 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 yes that is the one that u help me with yesterday; i did var_dump($row); and display all the values too, i need more than one values, i just dont want the values to repeat for no apprent reason Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278952 Share on other sites More sharing options...
teng84 Posted June 21, 2007 Share Posted June 21, 2007 add another condition SELECT messages.* FROM business_info,messages WHERE business_info.BusinessName=messages.BusinessName and messages.BusinessName='condition' Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278953 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 i get an error message Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278979 Share on other sites More sharing options...
teng84 Posted June 21, 2007 Share Posted June 21, 2007 can we have the sql statement Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278983 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-278994 Share on other sites More sharing options...
teng84 Posted June 21, 2007 Share Posted June 21, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279007 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279015 Share on other sites More sharing options...
teng84 Posted June 21, 2007 Share Posted June 21, 2007 thats pretty weir your question suppose to that easy any way from what table do you want to have the display is it from businnes or message Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279021 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 ok this is who it should be select from message where BusinessName="$_session['BusinessName'] that will be the easy way Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279025 Share on other sites More sharing options...
redarrow Posted June 21, 2007 Share Posted June 21, 2007 Please post the database info as ur join is way off cheers. also exsplain the out come u want ok. Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279030 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279045 Share on other sites More sharing options...
teng84 Posted June 21, 2007 Share Posted June 21, 2007 $sql="SELECT * FROM messages WHERE BusinessName='".$_SESSION['BusinessName']."' "; your missing ' this single qoute Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279067 Share on other sites More sharing options...
franknu Posted June 21, 2007 Author Share Posted June 21, 2007 Now, i am not displaying any values any idea why Quote Link to comment https://forums.phpfreaks.com/topic/56471-value-repatition/#findComment-279258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.