Jump to content

italicize options in drop-down box


raman

Recommended Posts

I have a page called query.html.On this page there is a form action called query.php which further has link to downxls.php.This prompts for the the download of an excel file and has the table headings displayed as Category,name and Brief Description.However there is no content fetched from The MYSQL database.This is the problem !!!

Also I have another question here that if I want to italicize the options in the drop-downbox on query.html page, how can I do that ? I have tried to use the <i> tags but doesn't seem to work Its like :

<option value='bla bla2'><i>bla bla2</i></option> but bla bla2 appears without any italics.

 

The code query.html:



<html>
<title>Query Browser<title>
<head>
<!--        Script by hscripts.com          -->
<!--        copyright of HIOX INDIA        -->
<!-- Free javascripts @ http://www.hscripts.com -->
<script language=javascript>
checked=false;
function checkedAll (orgcat) {
var aa= document.getElementById('orgcat');
if (checked == false)
          {
          checked = true
          }
        else
          {
          checked = false
          }
for (var i =0; i < aa.elements.length; i++)
{
aa.elements.checked = checked;
}
      }
</script>
<!-- Script by hscripts.com -->
<style type="text/css">
<!--
label { background-color: lavender; color: black; border:1 }
//-->
</style>

</head>
<body bgcolor='white'>
<table align="left" width=500 frame="void" cellspacing=1 cellpadding=3 bgcolor="">
<tr>
<td colspan=2 align ="center" bgcolor = "darkkhaki" height =30><font face="times new roman" size="5" color="black"><b>Query Form</b></td>
</tr></table>
<br><br><table cellspacing="10" cellpadding="10">
<tr><td> Search the organism</td><td>for the Category</td></tr>
<tr><td><form id='orgcat' enctype="multipart/form-data" action="query.php" method="post">
<select name="Organism[]" size="6" multiple="multiple">
<option value='bla bla1' selected>bla bla1</option>
<option value='bla bla2'>bla bla2</option>
<option value='bla bla3'>bla bla3</option>
<option value='bla bla4'>bla bla4</option>
<option value='bla bla5'>bla bla5</option>
<option value='bla bla6'>bla bla6</option>
<option value='bla bla7'>bla bla7</option>
<option value='bla bla8'>bla bla8</option>
<option value='bla bla9'>bla bla9</option>
<option value='bla bla10'>bla bla10</option>

</select></td>
<td>
<label>Adhes<input type="checkbox" name="Category[]" value="Adhes"></label>
<br>
<label>Invasi
<input type="checkbox" name="Category[]" value="Invasi"></label><br>
<label>Establish
<input type="checkbox" name="Category[]" value="Establish"></label><br>
<label>Pro
<input type="checkbox" name="Category[]" value="Pro"></label><br>
<label>Cyste
<input type="checkbox" name="Category[]" value="Cyste"></label><br>
<label>Heatcold
<input type="checkbox" name="Category[]" value="Heatcold"></label>
<br>
<label>Others
<input type="checkbox" name="Category[]" value="Others"></label><br>
<label>Select All
<input type="checkbox" name="checkall" onclick="checkedAll(orgcat);" ></label></td></tr></table>
<input type="Submit" value="Get it"
</form></table>
</html>

 

The code query.php :



<?php
$org=$_POST['Organism'];
$cat=$_POST['Category'];
$con= mysql_connect("localhost","root","prty30");
if(!$con)
  {
    die('Could not connect:'.mysql_error());
  }
mysql_select_db("Protvirdb",$con);
foreach($_POST['Organism'] as $org){
  foreach($_POST['Category'] as $cat){
    $ret=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'");
    $count=mysql_num_rows($ret);
    if ($count!=0){
      echo"<p> The number of records retrieved by your query is $count</p>";
      echo "<table border='1'>
<tr><th>Organism</th>
<th>Category</th>
<th>Protein</th>
<th>Brief Description</th>
</tr>";
      while($row=mysql_fetch_array($ret))
{
  $name=$row['Name'];
  $key=$row['SNo'];
  echo "<tr>";
  echo"<td><i>".$row['Organism']."</i></td>";
  echo"<td>".$row['Category']."</td>";
  echo"<td><a href=\"seq2.php?sn=$key\">".$row['Name']."</a></td>";
  echo"<td>".$row['Brief_Description']."</td>";
  echo "</tr>";
}
      echo"</table><br>";
      echo"<a href=\"downxls.php?Organism='$org'&Category='$cat'\">Download as excel file</a>";
    }
    else
    {
      echo "<p><b> No records were found in the category $cat</b></p>";
    }
  }
}
mysql_close($con);
?>

 

The code downxls.php:

 



<?php
$org=$HTTP_GET_VARS['Organism'];
$cat=$HTTP_GET_VARS['Category'];
$conn= mysql_connect("localhost","root","prty30");
if(!$conn)
  {
    die('Could not connect:'.mysql_error());
  }
mysql_select_db("Protvirdb",$conn);

// file name to be appear in output name. User can change their file name
// but this will give him a option for file name.
$file = 'testExcelFile.xls';
// start buffring
ob_start();
// sample dynamically generated data
echo '<table border="1"> ';
echo '<tr><th>Category</th><th>Protein</th><th>Brief Description</th></tr>';
if (isset($cat)){
  $rej=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'");
  while($row=mysql_fetch_array($rej))
    {
    echo "<tr>";
    echo"<td>".$row['Category']."</td>";
    echo"<td>".$row['Name']."</td>";
    echo"<td>".$row['Brief_Description']."</td>";
    echo "</tr>";
  }
}
echo"</table>";

mysql_close($conn);

$content = ob_get_contents();
ob_end_clean();
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: application/vnd.ms-excel;charset:UTF-8");
header('Content-length: '.strlen($content));
header('Content-disposition: attachment; filename='.basename($file));
// output all contents
echo $content;
exit;
?>


Link to comment
https://forums.phpfreaks.com/topic/125573-italicize-options-in-drop-down-box/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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