Jump to content

$result is cutting off results


Clinton

Recommended Posts

When it parses it's not pulling everything through.

 

$datecode displays right but $producttype and $productdescripton get cut off.

 

I.E., set as VARCHAR in db, $producttype in database reads 'MS NONEL' but is only parsing 'MS'. $productdescription in db reads '20 feet long' but is only parsing the '20'.

 

Any ideas on why this is happening?

 


$result = mysql_query("SELECT * FROM masterlist ORDER BY datecode");

if ($choice=="")
{
echo "<form action='' method='post'>";

echo "<select name='choice' value=''></option>";

while($nt=mysql_fetch_array($result))
{

echo "<option value=$nt[datecode]>$nt[datecode]</option>";
echo "<INPUT type=text name=type value=$nt[producttype]>";
echo "<INPUT type=text name=type value=$nt[productdescription]>";
}

echo "</select>";

echo "<input type='submit' value='Select'>";
}

else
echo "You have selected $choice$type. Have a nice day!";
?>

Link to comment
https://forums.phpfreaks.com/topic/109040-result-is-cutting-off-results/
Share on other sites

Thank you, that did work.

 

Now how about this...

 

... one of the echo statements below is not... echoing. How did I go wrong there?

 


<?php
if ($choice=="")
{
echo "<form action='' method='post'>";

echo "<select name='choice' value=''>Date Code</option>";

echo "Select the appropriate date code to view/edit: ";   ///////////////////<<<<<<<<------------- This one right here

while($nt=mysql_fetch_array($result))
{

echo "<option value=$nt[datecode]>$nt[datecode]</option>";
echo "<INPUT type=text name=type value='$nt[producttype]'>";
echo "<INPUT type=text name=type value='$nt[productdescription]'>";
}

echo "</select>";

echo "<input type='submit' value='Select'>";
}

else
echo "You have selected $choice$type. Have a nice day!";
?>

it echo'd just fine for me.

cleaned it up some:

<?php
if ($choice=="")
{
echo "<form action='' method='post'>\n";

echo "<select name='choice' value=''>Date Code</option>\n";

echo "Select the appropriate date code to view/edit: \n";   ///////////////////<<<<<<<<------------- This one right here

while($nt=mysql_fetch_array($result))
{

echo "<option value='{$nt['datecode']}'>{$nt['datecode']}</option>\n";
echo "<INPUT type=text name=type value='{$nt['producttype']}'>\n";
echo "<INPUT type=text name=type value='{$nt['productdescription']}'>\n";
}

echo "</select>\n";

echo "<input type='submit' value='Select'>\n";
}

else
echo "You have selected $choice$type. Have a nice day!";
?>

\n is a linebreak... makes things prettier when you view the source

 

Your problem is you aren't following HTML rules.

 

<select> elements should only have <option> elements in them, and should be closed with a </select> before any other elements are created.

 

Rules broken

echo "<select name='choice' value=''>Date Code</option>\n";

echo "Select the appropriate date code to view/edit: \n";   ///////////////////<<<<<<<<------------- This one right here

 

echo "<option value='{$nt['datecode']}'>{$nt['datecode']}</option>\n";
echo "<INPUT type=text name=type value='{$nt['producttype']}'>\n";
echo "<INPUT type=text name=type value='{$nt['productdescription']}'>\n";

 

I think you need to check this out

http://www.w3schools.com/HTML/

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.