Connecting Tech Pros Worldwide Forums | Help | Site Map

select and insert to database

Newbie
 
Join Date: Oct 2007
Posts: 22
#1: Mar 18 '08
hello there!!!.. i have a program here and i already select the field in database, when i type in textbox ex. new eng jour , the next page appear with the result of category i typed in the textbox with radio button.. i'll show the sample output..

AA00857167 / Tech engineering news / US / 0040084X
AA10740654 / New England journal of human services / US / 0277996X
AA00786207 / Proceedings of the New England Cardiovascular Society / US / 05484413
AA00755156 / New England journal of medicine / US / 00284793
AA00223135 / Industrial and engineering chemistry. News ed / US / 00976423

this is the result for new eng jour that im looking for.. if i will choose at fourth line with radio button, the output will be like this...

AA00755156 / New England journal of medicine / US / 00284793

the field name.. ID / TI / CY / ISSN..

thanks! i'm looking forward for your reply..

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#2: Mar 18 '08

re: select and insert to database


2 things:
I don't understand what the problem is and what you need help with.
And please can you post your code (with correct code tags), so that we can help you with that. Guessing how you have programmed is a waste of our time. We don't develop code, we fix code ;)
Newbie
 
Join Date: Oct 2007
Posts: 22
#3: Mar 19 '08

re: select and insert to database


Quote:
ok this is my code, the first code is a code for my first form, second code is for my second form and the last si for my third form
[HTML]<html>
<head>
<title></title>
</head>
<body>
<h5><u>Input Journal Name you want to search:</u></h5>

<form action = second.php method = "POST">
<p style="background-color:lavender;padding:10px;width=10%">
<input type = "text" name= "box"/><p>
<p><input type = "submit" value = "Enter"/>
<input type = "reset" value = "Clear"/></p>

</form>

</body>
</html>
[/HTML]

[PHP]<?php



$text = $_POST["box"];
$out = strtok($text, " ");
$sep = " ";

while ($out !== false)
{
$sep = $sep." (TI + ISSN + ID + CY) Like '%$out%'";

$out = strtok(" ");

if ($out !== false)
{
$sep = $sep. " AND ";
}else{
$sep = $sep. "";
}
}
$sql="SELECT MSNEW.ID, MSNEW.UI, MSNEW.GID, MSNEW.IID, MSNEW.TI, MSNEW.TIYOMI, MSNEW.ORGYOMI, MSNEW.CY, MSNEW.PU, MSNEW.YR, MSNEW.ISSN, MSNEW.ACRONYM, MSNEW.ABBREVIATION, MSNEW.NOTE, MSNEW.VTI, MSNEW.VTI2, MSNEW.VTI3 FROM MSNEW WHERE".$sep;
//$sql2 = "INSERT INTO WebOrderTest (YR, Vol, Issue, Spage, Epage, Author, Subj) VALUES (' ".$_COOKIE["PHPSESSID"]." ',' ".$_POST["YR"]." ',' ".$_POST["Vol"]." ', ' ".$_POST["Issue"]." ',' ".$_POST["Spage"]." ',' ".$_POST["Epage"]." ',' ".$_POST["Author"]." ',' ".$_POST["Subj"]." ')";

echo $sql."</BR>";
//echo "<align = \"center\">";
echo "<p align= center style=\"background-color:lavender;padding:8px;width=5 0%\">";
echo "Result for <b><u> $text </u></b></p>";


$res = ExecInforestaQuery($sql);

$x=0;
while($rec = odbc_fetch_array($res))
{
$ID=$rec['ID']." / ";
$TI=$rec['TI']." / ";
$CY=$rec['CY']." / ";
$ISSN=$rec['ISSN'];
// $output = explode(" ", $ID, $TI, $CY, $ISSN);

echo"<form action=\"third.php\" method=\"POST\">";
echo"<input name=\"ID[]\" type=\"radio\" id=\"ID[]\" value=\"".$ID, $TI, $CY, $ISSN. "\">".$ID, $TI, $CY, $ISSN."<br/>";


$y=0;
$Count=0;
while($x>$y)
{
if ($a[$y][0]==$out)
{
$a[$y][1]=$a[$y][1]+1;
$Count=1;
}
$y=$y+1;
}

if ($Count==0)
{
$a[$x][0]=$out;
$a[$x][1]=1;
$x=$x+1;
}
}

$X=0;
while($X<$x)
{
$X=$X+1;
}


echo "<p><input type=\"submit\" value=\"Enter\" /></p>";

odbc_free_result($res);

function db_connect_ctlg(){
$conn = odbc_connect("sys_foresta_ctlg", "sa", "");
if (!$conn) {
return NULL;
}else{
return $conn;
}
}

function ExecInforestaQuery($query){
$Set =db_connect_ctlg();
if (!$Set){
echo "DB Connect Failer!!<BR>";
return NULL;
}else{
$query_result = odbc_exec($Set,$query);
if (!$Set){
echo "Query Failer!!<BR>";
return NULL;
}else{
return $query_result;
}
}
}


?>

[/PHP]

[PHP]<?php

if(isset($_POST['ID']))
{
$e=$_POST['ID'];
$h=count($e);
$c=0;
$a = " ";

while($c<$h)
{
echo "<p align= center style=\"background-color:lavender;padding:8px;width=5 0%\"><b><u>";
$a = $a.$e[$c] ."</b></u>";

$c++;
}
}

?>

[/PHP]

Quote:
i want to display in the third form the result of the details that i've typed in textbox but it cannot be happen
Reply