tags:

views:

107

answers:

4

I am attempting following code to populate an UnOrdered List dynamically. The same type of code I am successfully using to populate a DropDown. But when I changed the tags to UnOrdered List, it is not working. When run, it just displays some tags instead of the actual output.

Where is the error:

<?php
    require("dbconnection.php");
    require("dbaccess.php");

    $divName = $_GET['DivName'];
    $ulName = $_GET['ControlName'];
    $query = $_GET['SqlQuery'];
echo $query;exit;
    dbconnection::OpenConnection();
    $result = dbaccess::GetRows($query);
?>
<ul id="<?php echo $ulName; ?>" name="<?php echo $ulName; ?>">
<?php while($row=mysql_fetch_array($result))
{ ?>
    <li><?php echo $row[1]; ?>"></li>
<?php } ?>
</ul>

The code that I used to populate a DropDown is below: It works absolutely fine:

<?php
    require("dbconnection.php");
    require("dbaccess.php");

    $dropdownControlName = $_GET['DropDownControlName'];
    $query = $_GET['SqlQuery'];
    dbconnection::OpenConnection();
    $result = dbaccess::GetRows($query);
?>
<select id="<?php echo $dropdownControlName; ?>" name="<?php echo $dropdownControlName; ?>">
<option>Select from the list</option>
<?php while($row=mysql_fetch_array($result))
{ ?>

    <option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>

<?php } ?>
</select>
+1  A: 

Don't know Php but what this line doing :

echo $query;exit;
Edelcom
That's basically stopping execution from that point.
Douwe Maan
Sorry. I removed that line while using. I used it previously to know what is coming to $query.
RPK
+1  A: 

The error is here:

<li><?php echo $row[1]; ?>"></li>

should be this:

<li><?php echo $row[1]; ?></li>
Karsten
+1  A: 

Are you sure that you have to use the second field of the result set?

    <li><?php echo $row[1]; ?>"></li> 

There is an extra >" there.

Can you show us the resulting html code ?

SORRY: I was away from the PC for some minutes before posting, just saw that I answered the same as the following answer.

Edelcom
Yes, the error was that extra ">
RPK
+1  A: 

HI,

I used your code and gave some constant values and i got the following out put.

Out Put:

  • 1">
  • 2">
  • 3">
  • 4">

    Used code:

    `
  • ">
  • `

and final Conclusion is, this prints the unordered list and i think yo may check your

echo $row[1]; part for any html out puts.

Note: "> This tag comes because of in your code having this value 
Ranga