Russia Posted January 30, 2011 Share Posted January 30, 2011 Hello, im trying to make a dropdown show up for every single row gotten from the database table. Instead it shows only one for the first row. Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example Form</title> <link rel="stylesheet" type="text/css" href="dd.css" /> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.dd.js"></script> </head> <body> <?php mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("test")or die("cannot select DB"); $tbl_name="test_mysql"; $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <form name="form1" method="post" action=""> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Row</strong></td> <td align="center"><strong>Month Date</strong></td> <td align="center"><strong>Message</strong></td> <td align="center"><strong>Title</strong></td> <td align="center"><strong>Icon</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td> <td align="center"><input name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="<?php echo $rows['month']; ?>"> <input name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="<?php echo $rows['date']; ?>"> </td> <td align="center"><input name="message[]" size="50" type="text" id="message" value="<?php echo $rows['message']; ?>"></td> <td align="center"><input name="title[]" size="50" type="text" id="title" value="<?php echo $rows['title']; ?>"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </tr> <?php } ?> <tr> <td colspan="4" align="center"><br><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> <script language="javascript" type="text/javascript"> function showvalue(arg) { alert(arg); //arg.visible(false); } $(document).ready(function() { try { oHandler = $(".mydds").msDropDown().data("dd"); oHandler.visible(true); //alert($.msDropDown.version); //$.msDropDown.create("body select"); $("#ver").html($.msDropDown.version); } catch(e) { alert("Error: "+e.message); } }) </script> <hr> <?php if (isset($_POST['Submit'])) { for($i=0;$i<$count;$i++){ $month = $_POST['month']; $date = $_POST['date']; $message = $_POST['message']; $title = $_POST['title']; $monthday = $month[$i]."<br>".$date[$i]; $sql1="UPDATE $tbl_name SET monthday='$monthday', month='$month[$i]', date='$date[$i]', message='" . mysql_real_escape_string($message[$i]) . "', title='" . mysql_real_escape_string($title[$i]) . "' WHERE id='$id[$i]'"; //$sql1="UPDATE $tbl_name SET monthday='$monthday', month='$month[$i]', date='$date[$i]', message='$message[$i]', title='$title[$i]' WHERE id='$id[$i]'"; $result1 = mysql_query($sql1); } header("location:update2.php"); } ?> </body> </html> <BR> I have no idea if it has to do with the PHP, HTML, or JAVASCRIPT. So if someone can tell me what is going on I would be happy. Here is how it looks: Youl see it shows the fields but not the dropdown... Please help and thank You! Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 remove the javascript and see if the problem remains. if so, it's the javascript. Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 If I remove the js the form dissapears... >.> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 you probably should remove the <tr> and <td> tags after the opening form tag and add a closing table tag before the closing form tag. invalid html can sometimes appear as a blank page. Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 tried that, I saw I was missing a </td>. I added that but theres still an error that the rest of the drop downs arent showing. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 if you just got a blank page after removing the javascript, there may have been a php error causing a blank page to be sent to the browser. view the source. do the dropdowns appear in the html source? if so, the html is bad or the javascript is hiding the other dropdowns. i would copy the source and use an html validator (or your script editor, if it validates html) to see if there is anything in the html messing things up. Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 Yes the dropdown does show DUHH... you can see the picture.... It doesnt show it for every single one like it supposed to... It only shows it for the first one... Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 30, 2011 Share Posted January 30, 2011 Yes the dropdown does show DUHH... you can see the picture.... It doesnt show it for every single one like it supposed to... It only shows it for the first one... DUH. I meant the other ones, in the HTML, using View Source to look at the HTML output. DUH! Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 Yeah, it does seem to show... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Example Form</title> <link rel="stylesheet" type="text/css" href="dd.css" /> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.dd.js"></script> </head> <body> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; background-color: #FFFFCC; padding: 2px; height: 14px; width: 200px; border: 1px solid #7F9DB9; } --> <form name="form1" method="post" action=""> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Row</strong></td> <td align="center"><strong>Month Date</strong></td> <td align="center"><strong>Message</strong></td> <td align="center"><strong>Title</strong></td> <td align="center"><strong>Icon</strong></td> </tr> <tr> <td align="center">1</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="FEB"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="12"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="Stocking up on supplies for the return of free trade and the Wilderness? If your bank is bursting at the seams, don’t forget that registering your email address will unlock 10 extra free bank spaces whether you're a member or not!"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="YES TESTING"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td align="center">2</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="JAN"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="04"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="Stocking up on supplies for the return of free trade and the Wilderness? If your bank is bursting at the seams, don’t forget that registering your email address will unlock 10 extra free bank spaces whether you're a member or not!"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="Register Your Email – Bank Space Reminder"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td align="center">3</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="JAN"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="01"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="For too long the revenant menace has terrorised the Wilderness. With the return of the old Wilderness the revenants have finally outstayed their welcome. Help the RuneScape team drive out this menace for the final time!"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="Banishing the Revenants"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td align="center">4</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="JAN"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="09"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="tesssssstfdfssfs"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="sdfsdfsfsdfsf"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td align="center">5</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="JAN"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="22"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="IMSAOIUNDSBDUBVSYDSssaadsdadasda"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="SDAdffdssd"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td align="center">6</td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="month[]" MAXLENGTH="3" size="3" type="text" id="month" value="FEB"> <input style="border: 1px solid #C3C3C3;height: 20px;" name="date[]" MAXLENGTH="2" size="2" type="text" id="date" value="12"> </td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="message[]" size="70" type="text" id="message" value="OOOMMGGGGGadsadadaddsadadaddasasdad"></td> <td align="center"><input style="border: 1px solid #C3C3C3;height: 20px;" name="title[]" size="70" type="text" id="title" value="YES TESTING"></td> <td align="center"> <select name="test[]" style="display:none; width:200px" class="mydds"> <option value="icon_phone.gif" title="icon/icon_phone.gif">Phone</option> <option value="icon_sales.gif" title="icon/icon_sales.gif">Graph</option> </select> </td> </tr> <tr> <td colspan="4" align="center"><br><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> <script language="javascript" type="text/javascript"> function showvalue(arg) { alert(arg); //arg.visible(false); } $(document).ready(function() { try { oHandler = $(".mydds").msDropDown().data("dd"); oHandler.visible(true); //alert($.msDropDown.version); //$.msDropDown.create("body select"); $("#ver").html($.msDropDown.version); } catch(e) { alert("Error: "+e.message); } }) </script> <hr> <br> </body> </html> I have no idea why its not showing up tho... Is it the javascript problem or what? Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 Dame Im having so much trouble with this. The thing is I think the js file is encodes so I cant change the value so it shows up multiple times... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 30, 2011 Share Posted January 30, 2011 When I paste in your HTML output, I get no dropdowns, until I change all the style="display:none;" attributes to display:block; then they all show. But I don't have your js files, so that may or may not be the actual problem. Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 Yeah for some reason when I do that it messes up the whole html output. Do you want to see a video of how it looks? Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 OKAY OKAY!!! that seemed to work, but when I load the page it loads the dropdowns as already opened up... Like it doesnt show one line, it shows all of them with all the options dropdowned Quote Link to comment Share on other sites More sharing options...
Russia Posted January 30, 2011 Author Share Posted January 30, 2011 Does anyone have any idea of why it shows it as the dropdown form already open? Quote Link to comment Share on other sites More sharing options...
Russia Posted January 31, 2011 Author Share Posted January 31, 2011 So yeah has anyone really figured out why the dropdown appears open when I load the page? Here is a video of the error: Id also really be glad if someone tell me why this error shows up. Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\update2.php:58) in C:\wamp\www\update2.php on line 123 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.