zhshero Posted November 15, 2010 Share Posted November 15, 2010 I need help figuring out why it dose this \/ here the page <?php require_once('../settings.php'); checkLogin('1 2'); ?> <? $userfinal = get_username($_SESSION['user_id']); // get the messages from the table. $get_messages = mysql_query("SELECT message_id FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error()); $num_messages = mysql_num_rows($get_messages); // display each message title, with a link to their content echo '<center><ul>'; for($count = 1; $count <= $num_messages; $count++) { $row = mysql_fetch_array($get_messages2); //if the message is not read, show "(new)" after the title, else, just show the title. $id=$_GET["delete_id"]; mysql_query("DELETE * FROM messages WHERE message_id='$id' "); if($row['message_read'] == 0) { ?> <head> <title>ZhsHero Friends</title> <link href="/themes/theme1/default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> <h1>ZhsHero Friends</h1> <h2>Menu</h2> <ul> <li class="first"><a href="home.php" accesskey="1" title="">Home</a></li> <li><a href="mymembers.php" accesskey="2" title="">members</a></li> <li><a href="#" accesskey="3" title="">Services</a></li> <li><a href="#" accesskey="4" title="">About</a></li> <li><a href="#" accesskey="5" title="">Contact</a></li> </ul> </div> <div id="content"> <div id="colOne"> <h3><?php echo 'Welcome ' . get_username ( $_SESSION['user_id'] ) . ''; ?></h3> <ul class="list"> <img src="<? echo get_main_P ( $_SESSION['user_id'] ) ?>" border=1 width="150" height="150"> </ul> <p> </p> <h3>news box</h3> <p>new box comming soon</p> </div> <div id="colTwo"> <p> <form> <a href="read_message.php?messageid=<? echo $row['message_id'] ?>"> <img src="<? echo $row['user_photo'] ?>" width="50" height="50" /> <a href="read_message.php?messageid=<? echo $row['message_id'] ?>"> <? echo $row['message_title'] ?></a> <font color="red">(unread)</font> </a> <? }else{ ?> <br> <a href="read_message.php?messageid=<? echo $row['message_id'] ?>"> <img src="<? echo $row['user_photo'] ?>" width="50" height="50" /> <a href="read_message.php?messageid=<? echo $row['message_id'] ?>"> <? echo $row['message_title'] ?></a> <font color="green">(read)</font> </a> <? }} echo '</ul>'; echo '<form name="newmsgfrm" method="post" action="new_message.php">'; echo '<input type="submit" value="Send a New Message">'; echo '</form>'; echo '<form name="backfrm" method="post" action="index.php">'; echo '<input type="submit" value="Back to Home">'; echo '</form>'; ?> </form> </p> </div></div> <div id="footer"> <p>Copyright (c) 2006 Sitename.com. All rights reserved. Design by <a href="http://freecsstemplates.org/">Free CSS Templates</a>.</p> </div> <div style="font-size: 0.8em; text-align: center;"> <br /> Design downloaded from Zeroweb.org: <a href="http://www.zeroweb.org">Free website templates, layouts, and tools.</a><br /> <br /> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/218791-need-help-with-my-php-page/ Share on other sites More sharing options...
Pikachu2000 Posted November 15, 2010 Share Posted November 15, 2010 A major portion of your HTML is being output from within the for() loop, so for every message retrieved by the first database query, it will output it all over again. Quote Link to comment https://forums.phpfreaks.com/topic/218791-need-help-with-my-php-page/#findComment-1134731 Share on other sites More sharing options...
jcbones Posted November 15, 2010 Share Posted November 15, 2010 You are asking it to display all of that data for each message Id there is in the database. Your problem starts here: for($count = 1; $count <= $num_messages; $count++) Find everything that is inside of that loop, and it will display that, everytime the loop runs. Which, like I said, is everytime it finds a message id in the database. PS> Beat by Pik again! Quote Link to comment https://forums.phpfreaks.com/topic/218791-need-help-with-my-php-page/#findComment-1134734 Share on other sites More sharing options...
zhshero Posted November 15, 2010 Author Share Posted November 15, 2010 Thanks you to i figured it out would of taken me days Quote Link to comment https://forums.phpfreaks.com/topic/218791-need-help-with-my-php-page/#findComment-1134735 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.