Jump to content

Dropdown not showing up for every row in database.


Russia

Recommended Posts

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:

 

HreDY.jpg

 

Youl see it shows the fields but not the dropdown... Please help and thank You!

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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