I posted this one PHPFREAKS but couldn't get an answers. I thought I would try here and see if someone can figure this out... My problem is I am trying to output data from my database and put a checkbox before the data.... now the data will come out just fine if i remove the followng line. echo "<input type=\"checkbox\" name=\"$u_msgid[$i]\" value=\"checkbox\" />"; Code (markup): But with that line in the output comes out looking like this. The full code looks like this. <?php include 'session.php'; include 'dbconnect.php'; $query = "SELECT mailFrom FROM mail WHERE rcpt = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); $querySubj = "SELECT mailSubject FROM mail WHERE rcpt = '$username'"; $resultsSubj = mysql_query($querySubj); $numSubj = mysql_num_rows($resultsSubj); $queryMsgID = "SELECT msgid FROM mail WHERE rcpt = '$username'"; $resultsMsgID = mysql_query($queryMsgID); $numMsgID = mysql_num_rows($resultsMsgID); //echo '<form id="form1" name="form1" method="post" action="deleteMessage.php">'; while($u_name=mysql_fetch_array($results) and $u_subj=mysql_fetch_array($resultsSubj) and $u_msgid=mysql_fetch_array($resultsMsgID)) { for($i = 0; $i < $num; $i++) { echo "<input type=\"checkbox\" name=\"$u_msgid[$i]\" value=\"checkbox\">"; echo "<a href =\"index.php?username=$u_name[$i]\">$u_name[$i]</a>"; echo "<a href=\"\">$u_subj[$i]</a>"; } echo "<br />"; } //echo '</form>'; ?> Code (markup):
I posted a screenshot of the output in the post... notice all the extra checkboxes it is generating after the subject line?
The HTML output is coming out like this... it's adding way to many phantom checkboxes and blank URLs <form id="form1" name="form1" method="post" action="deleteMessage.php"> <input type="checkbox" name="1" value="checkbox" /> <a href ="index.php?username=jfrank">jfrank</a> <a href="">Test!</a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a><br /> <input type="checkbox" name="2" value="checkbox" /> <a href ="index.php?username=jfrank">jfrank</a> <a href="">Test!</a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a><br /> <input type="checkbox" name="3" value="checkbox" /> <a href ="index.php?username=jfrank">jfrank</a> <a href="">Test!</a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a> <input type="checkbox" name="" value="checkbox" /> <a href ="index.php?username="></a> <a href=""></a><br /> etc etc... Code (markup):
because i'm a newb at PHP and am unsure how to seperate the colums in the final output when spitting out the links.
ok here is the right way to do this : <?php include 'session.php'; include 'dbconnect.php'; $query = "SELECT mailFrom, mailSubject,msgid FROM mail WHERE rcpt = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); //echo '<form id="form1" name="form1" method="post" action="deleteMessage.php">'; while($rec=mysql_fetch_array($results)) { echo "<input type=\"checkbox\" name=\"".$rec['msgid']."\" value=\"checkbox\">"; echo "<a href =\"index.php?username=".$rec['mailFrom']."\">".$rec['mailFrom']."</a>"; echo "<a href=\"\">".$rec['mailSubject']."</a>"; echo "<br />"; } //echo '</form>'; ?> PHP: