0

haiii all,

i have a php working code for dropdown list,i am unable to display that in a table,i am getting error if i write that code in <td> </td>
i am able to include buttons...but why i am i unable to include dropdownlist?

so can i place that code in another .php file and try to execute between <td> </td>

<td> dropdownlist.php </td> ???????? please anyone help me regarding this.....

example:

Items Select Insert
john dropdownlist Insertbutton
Marry dropdownlist insertbutton
Nancy dropdownlist insertbutton


if i select dropdownlist item and click on insert,it should insert in a datanabe table.

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by TySkby
0

Try using

include 'dropdownlist.php'

and printing a variable from that in your <td> tags.

Example:
dropdownlist.php:

$ddlist="**your dropdownlist html goes here**"

Then
index.php (or whatever):

include 'dropdownlist.php';
...
print("<td>$ddlist</td>");
0

so can i write

<td> include 'dropdownlist.php' </td>

its not working!!!!

0

<?php
$db =mysql_connect("localhost", "root","root");
mysql_select_db("reports",$db);
$result = mysql_query("SELECT * FROM alertssummary",$db);
if ($myrow = mysql_fetch_array($result))
{

echo"<form method='POST' action='delete.php'>";
echo "<table border=1>\n";
echo "<tr><td>Id</td><td>AlertsDisribution</td><td>Label</td><td>Affects</td><td>Variations</td><td>Insert</td><td>Delete</td></tr>\n";
do {
printf("<tr><td>%s</td><td>%s</td><td>%s</td> <td>%s</td> <td>%s</td>
<td><input type='checkbox' name='checkbox1[]' value='%s'/></td>

td> """""""""""""""""i should get it here"""""""""""""""""""""""""""""""""''''''' </td>
<td><input type='checkbox' name='checkbox[]' value='%s'/></td>
</tr>\n",$myrow["Id"],$myrow["AlertsDistribution"], $myrow["label"],$myrow["Affects"],$myrow["Variations"],$myrow["Id"],$myrow["Id"]);
}
while ($myrow = mysql_fetch_array($result));

echo "</table> <p> <center><input id='delete' type='submit' class='button' name='delete' value='Delete Selected Items'/></p></center></form>";

$result2=mysql_query("SELECT Id,owasp FROM Owasp",$db);
echo "<center><select name=Owasp value=''><option>Owasp List</option></center>";
while($nt=mysql_fetch_array($result2))
{
echo "<option value=$nt[Id]>$nt[owasp]</option>";
}
echo "</select>";

echo "<p><center><input id='insert' type='submit' class='button' name='insert' value='Insert Selected Items'/></center></p>";
mysql_close($db);

}

?>

code in red is for dropdownlist, i am able to display it under table but i am not able to do it between <td> </td> tag

0

Here's how the include file is called...

<?php
include("filename.php");
?>

There is no <td> before and after the include...

0

Here is your code you posted, modified:

<?php
include 'selectlist_options.php';
$db =mysql_connect("localhost", "root","root");
mysql_select_db("reports",$db);

$result = mysql_query("SELECT * FROM alertssummary",$db);

include 'dropdownlist.php'; //Add this line, which retrieves all of the code in dropdownlist.php

if ($myrow = array($result))
{

echo"<form method='POST' action='delete.php'>";
echo "<table border=1>\n";
//Below, use $select_markup (or any variable you want) as the variable containing the string generated in selectlist_options.php
echo "<tr><td>Id</td><td>AlertsDisribution</td><td>Label</td><td>Affects</td><td>Variations</td><td>Insert</td><td>Delete</td></tr>\n";
printf("<tr><td>%s</td><td>%s</td><td>%s</td> <td>%s</td> <td>%s</td>
<td><input type='checkbox' name='checkbox1[]' value='%s'/></td>
<td>$select_markup</td>
<td><input type='checkbox' name='checkbox[]' value='%s'/></td>
</tr>\n",$myrow["Id"],$myrow["AlertsDistribution"], $myrow["label"],$myrow["Affects"],$myrow["Variations"],$myrow["Id"],$myrow["Id"]);

while ($myrow = mysql_fetch_array($result));
echo "</table> <p> <center><input id='delete' type='submit' class='button' name='delete' value='Delete Selected Items'/></p></center></form>";
echo "<p><center><input id='insert' type='submit' class='button' name='insert' value='Insert Selected Items'/></center></p>";
mysql_close($db);

}

?>

Then, in another file (dropdownlist.php), the code that generates the list:

<?php

$result2=mysql_query("SELECT Id,owasp FROM Owasp",$db);
echo "<center><select name=Owasp value=''><option>Owasp List</option></center>";
while($nt=mysql_fetch_array($result2))
{
$select_markup = $select_markup."<option value=$nt[Id]>$nt[owasp]</option>";
}
echo "</select>";

?>

Edited by TySkby: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.