I have a table named title with the column keywords. the data in this column keywords is not a single word but many seperated with ; when stored in the table.
To access this data one by one, i used explode command and the datas are displayed in a select box.This is the code which i wrote for getting the keywords out of the paper_title table. It is named as keyword.php. Here this keyword column contains data that is seperated by ; and needs to be splitted and all the words to be entered in to the select box.
<?php
require("the_jewel.php");
$sql1="SELECT m_rid
FROM paper_exp_mod_con
GROUP BY m_rid
ORDER BY m_rid ASC";
$stmt1 = OCIParse($conn, $sql1);
OCIExecute($stmt1);
while ($temp = OCIFetch($stmt1))
{
$paper_id =OCIResult($stmt1, "M_RID");
$sql = "SELECT keywords
FROM schmitzs.paper_details
WHERE m_rid = $paper_id";
$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
while ($temp = OCIFetch($stmt))
{
$keyword1 = OCIResult($stmt, "KEYWORDS");
$keywords = explode(";", $keyword1);
$no_of_keywords = count($keywords);
for ($i=0; $i <= $no_of_keywords-1; $i++)
{
//$keys[$i]='';
if ($keys[$i]!= $keywords[$i])
{
$keys[$i] = $keywords[$i];
}
}
unset($keywords);
$no_of_keys = count($keys);
for ($j=0; $j <= $no_of_keys; $j++)
{
echo "<option value='$keys'>$keys[$j]</option>";
}
}
}
?>
after selecting a data from the select box, i need this data for further sql processing
<form action="show_inserted_papers.php" method="post">
<table>
<tr>
<td><input type ="radio" name="category" value="keyword"> Keyword: </td>
<td colspan="2">
<select name="keyword">
<?php
require("keyword.php");
?>
</select></td>
</tr>
<tr>
<td> </td>
<td align="right" colspan="2"><input type='submit' name='select_paper' value='Show paper'></td>
</tr>
</table>
</form>
this is the code present in show_inserted_papers.php.it takes Array instead of the keyword which was selected from the select box and the sql statement looks like this:-
SELECT p_title FROM schmitzs.paper_details WHERE keywords like 'Array'
<?php
$category = $HTTP_POST_VARS['category'];
if ($category == 'keyword')
{
if ($HTTP_POST_VARS['keyword'])
{
$keyword = $HTTP_POST_VARS['keyword'];
$sql = "SELECT p_title
FROM schmitzs.paper_details
WHERE keywords like '$keyword'
ORDER BY m_rid";
echo "$sql";
$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
while ($temp = OCIFetch($stmt))
{
$title = OCIResult($stmt, 'P_TITLE');
echo "$title";
}
}
}
Help me in this regard.