hello all Can anybody help me out with the Php and Mysql code. The mysql query does not fetch data from the database. The example file are mentioned below:
This is the code for making a drop down list. <html> <head>
<script> function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","isolates.php?q="+str,true); xmlhttp.send(); } } </script></head>
<body>
<select name="q" onchange="showUser(this.value)">
<option value="">Select a strain:</option>
<option value="1">ABNIH5</option>
<option value="2">ABNIH5</option>
<option value="3">ABNIH5</option>
<option value="4">ABNIH5</option>
</select>
</form>
</body> </html>
and this is another code to fetch data. $q = $_GET['q']; $dbhost = 'abc'; $dbuser = 'abc'; $dbpass = 'abc'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if (! $conn) { die ('could not connect: ' . mysql_error()); }
if (!mysql_select_db('xyz', $conn)) { echo 'Could not select database'; exit; }
$sql= "SELECT Genome_id,Genome_name,Genome_status,Completion_date,Publication FROM tablename WHERE Strain_id LIKE '%".$q."%'";
$result = mysql_query($sql, $conn);
echo "
| Genome_id | Genome_name | Genome_status | Completion_date | Publication |
|---|---|---|---|---|
| " . $row['Genome_id'] . " | " . $row['Genome_name'] . " | " . $row['Genome_status'] . " | " . $row['Completion_date'] . " | " . $row['Publication'] . " |
?>
</body> </html>
0 answers
No answers yet.
Log in to answer this question.
Hello sharmatina189059!
We believe that this post does not fit the main topic of this site.
This is not a bioinformatics question, I'm sorry. Maybe try Stack Overflow?
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!