Clinton Posted June 6, 2008 Share Posted June 6, 2008 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!"; ?> Quote Link to comment Share on other sites More sharing options...
amites Posted June 6, 2008 Share Posted June 6, 2008 try dumping the results and see what shows up Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 6, 2008 Share Posted June 6, 2008 All HTML values must be enclosed in " ", and keys for arrays should be enclosed in ' ' (unless parsing a variable key). Fix those and it'll work (the HTML thing is the real problem though, the second one is just good practice). Quote Link to comment Share on other sites More sharing options...
Clinton Posted June 6, 2008 Author Share Posted June 6, 2008 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!"; ?> Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 6, 2008 Share Posted June 6, 2008 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!"; ?> Quote Link to comment Share on other sites More sharing options...
Clinton Posted June 6, 2008 Author Share Posted June 6, 2008 Thanks jons... and real quick, what are the \n's for? Quote Link to comment Share on other sites More sharing options...
discomatt Posted June 6, 2008 Share Posted June 6, 2008 \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/ Quote Link to comment 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.