Jump to content

Echo HTML coming out all jacked up...


advancedfuture

Recommended Posts

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!

 

l_46670cf6c5b03dc72224c83a4884e692.jpg

 

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.

Link to comment
https://forums.phpfreaks.com/topic/85262-echo-html-coming-out-all-jacked-up/
Share on other sites

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..

 

l_676e861dff3ffeaab925092ccbc15c68.jpg

 

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...

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);

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.