advancedfuture Posted January 9, 2008 Share Posted January 9, 2008 So this is the code, it should print a checkbox, the senders name, and the subject all one one line. 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>'; ?> However instead it outputs looking like this! Now if i remove the code to insert the checkbox... all the messages get printed correctly line by line. And i don't know where all those extra checkboxes keep showing up from. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/ Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 You have your { in the wrong place, it should be after the WHILE not after the echo. Also, you dont want the form tag in your WHILE loop I dont think. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434977 Share on other sites More sharing options...
advancedfuture Posted January 9, 2008 Author Share Posted January 9, 2008 yeah I moved the form tags outside of the loop and it prints out each line now... but still keeps adding a ton of checkboxes... updated the code in the box.. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434979 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Whatever $num is set to is how many you get. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434982 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 View the source and look at the checkbox names/values. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434984 Share on other sites More sharing options...
advancedfuture Posted January 9, 2008 Author Share Posted January 9, 2008 Whatever $num is set to is how many you get. if that was the case then shouldnt it also print out that many times '$u_name' and $u_subj'?? i put the form tags outside of the while loop and this is the new output.. updated code.... 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>'; ?> The output HTML is showing up as <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... Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434987 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 What sets $num? Sounds like everything past 0 is empty. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434997 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 If you want to echo the array, you should probably look at FOREACH instead of your for loop. Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-434999 Share on other sites More sharing options...
advancedfuture Posted January 9, 2008 Author Share Posted January 9, 2008 still doesnt explain why if i comment out this one line. //echo "<input type=\"checkbox\" name=\"$u_msgid[$i]\" value=\"checkbox\" />"; that all of the sudden the output appears just perfectly. jfrank Test! jfrank lulz jfrank NUKKA WAH!! jfrank HARDY HAR HAR HAR!!!! jfrank HARDY HAR HAR HAR!!!! $num is set via the following code. $query = "SELECT mailFrom FROM mail WHERE rcpt = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-435008 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Probably because you have two arrays going in the same while loop Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-435012 Share on other sites More sharing options...
advancedfuture Posted January 9, 2008 Author Share Posted January 9, 2008 3 arrays in the while loop actually lol... so what would be my alternative solution? Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-435041 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 Can you post more of your code? Where are $resultsSubj and $resultsMsgID defined? Quote Link to comment https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/#findComment-435085 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.