Jump to content

biotech

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

biotech's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the point is that i dont have access to database yet but hopefully will get is soon, ok i will try you suggestion and get back to you. thanks man, for looking into it
  2. did you make this to work,i mean the search thing..i need this badly too
  3. i will look into databases when i make this to work first i tried this approach but this doesnt work plese help [code] $titleValue=$_GET['titleValue']; for($i=0;$i<$total_books;$i++){ if(strcasecmp($titleValue,$titles[$i][0])==0) { //this is the place we have to add partial match if(stristr($titles[$i][0],$titleValue) === TRUE) { $book_title=$titles[$i][0]; $book_price_us=$titles[$i][1]; $book_price_uk=$titles[$i][2]; $book_isbn=$titles[$i][3]; $book_author=$titles[$i][4]; $book_year=$titles[$i][5]; $book_discount=$titles[$i][6]; $book_category=$titles[$i][7]; $book_description=$titles[$i][8]; $book_image=$titles[$i][9]; $book_link=$titles[$i][10]; $book_link2=$titles[$i][11]; $books [] = array('title' => $book_title,   'USprice' => $book_price_us,   'UKprice' => $book_price_uk,   'isbn' => $book_isbn,   'author' => $book_author,   'year' => $book_year,   'discount' => $book_discount,   'category' => $book_category,   'description' => $book_description,   'image' => $book_image,   'link' => $book_link,   'link2' => $book_link2);   $m++; } } } [/code]
  4. hi, guys, or should i say freaks  ;D i need help though...i have tried to make a script for searching the books and its related data i came up with something but it lacks one major feature, the user have to supply the exact name of the book, but that is just bad you will agree i am sure. it doesnt have to be case sensitive but this is just what i need badly. i am not a php freak but want to become one in a time, since that happen i will have to bother you  ;D here is the script i came up so far (it doesnt use sql yet, database is just simple two dimensional array): [code] <?php   $books = array();   $total_books=4;   $m=0;  //number of matches   //array 'title' 0,  'price us 1 and uk 2 ','ISBN' 3, 'author' 4, 'year' 5, discount 6, category 7,description 8 ,image 9 , link 10   $titles=array(array('book title 1',10,10,'1-23456-789-0','author name','2006','55%','Religion','description','1-23456-789-0.jpg','http://www.somelink.com/','http://www.somelink2.com/'),                 array('book title 1',10,10,'1-23456-789-0','author name','2006','55%','Religion','description','1-23456-789-0.jpg','http://www.somelink.com/','http://www.somelink2.com/'),                 array('book title 1',10,10,'1-23456-789-0','author name','2006','55%','Religion','description','1-23456-789-0.jpg','http://www.somelink.com/','http://www.somelink2.com/'),                 array('book title 1',10,10,'1-23456-789-0','author name','2006','55%','Religion','description','1-23456-789-0.jpg','http://www.somelink.com/','http://www.somelink2.com/')); $titleValue=$_GET['titleValue'];  //the title name passed from other *.php //check is there any match for($i=0;$i<$total_books;$i++){ //ignore case sensitive strings         if(strcasecmp($titleValue,$titles[$i][0])==0) {               //fill out our arrray with matches               $book_title=$titles[$i][0]; $book_price_us=$titles[$i][1]; $book_price_uk=$titles[$i][2]; $book_isbn=$titles[$i][3]; $book_author=$titles[$i][4]; $book_year=$titles[$i][5]; $book_discount=$titles[$i][6]; $book_category=$titles[$i][7]; $book_description=$titles[$i][8]; $book_image=$titles[$i][9]; $book_link=$titles[$i][10]; $book_link2=$titles[$i][11]; $books [] = array('title' => $book_title,   'USprice' => $book_price_us,   'UKprice' => $book_price_uk,   'isbn' => $book_isbn,   'author' => $book_author,   'year' => $book_year,   'discount' => $book_discount,   'category' => $book_category,   'description' => $book_description,   'image' => $book_image,   'link' => $book_link,   'link2' => $book_link2);   $m++;  //track number of matches } } //this value will be pased back in order to see is there any matches if($book_title==""){ $query_match='0'; } else $query_match='1'; //make xml to pass back header('Content-Type: text/xml'); $dom=new DOMDocument(); $response=$dom->createElement('response');//root $dom->appendChild($response); $books_dom=$dom->createElement("books"); foreach( $books as $book )   {   $b = $dom->createElement( "book" );     $title = $dom->createElement( 'title' );   $title->appendChild(   $dom->createTextNode( $book['title'] )   );   $b->appendChild( $title );     $USprice = $dom->createElement( "USprice" );   $USprice->appendChild(   $dom->createTextNode( $book['USprice'] )   );   $b->appendChild( $USprice );     $UKprice = $dom->createElement( "UKprice" );   $UKprice->appendChild(   $dom->createTextNode( $book['UKprice'] )   );   $b->appendChild( $UKprice );     $isbn = $dom->createElement( "isbn" );   $isbn->appendChild(   $dom->createTextNode( $book['isbn'] )   );   $b->appendChild( $isbn );     $author = $dom->createElement( "author" );   $author->appendChild(   $dom->createTextNode( $book['author'] )   );   $b->appendChild( $author );     $year = $dom->createElement( "year" );   $year->appendChild(   $dom->createTextNode( $book['year'] )   );   $b->appendChild( $year );     $discount = $dom->createElement( "discount" );   $discount->appendChild(   $dom->createTextNode( $book['discount'] )   );   $b->appendChild( $discount );     $category = $dom->createElement( "category" );   $category->appendChild(   $dom->createTextNode( $book['category'] )   );   $b->appendChild( $category );     $description = $dom->createElement( "description" );   $description->appendChild(   $dom->createTextNode( $book['description'] )   );   $b->appendChild( $description );     $image = $dom->createElement( "image" );   $image->appendChild(   $dom->createTextNode( $book['image'] )   );   $b->appendChild( $image );     $link = $dom->createElement( "link" );   $link->appendChild(   $dom->createTextNode( $book['link'] )   );   $b->appendChild( $link );     $link2 = $dom->createElement( "link2" );   $link2->appendChild(   $dom->createTextNode( $book['link2'] )   );   $b->appendChild( $link2 );     $books_dom->appendChild( $b );   }   $response->appendChild($books_dom);   $match=$dom->createElement('match'); $matchText=$dom->createTextNode($query_match); $match->appendChild($matchText); $number_of_matches=$dom->createElement('number_of_matches'); $number_of_matches_text=$dom->createTextNode($m); $number_of_matches->appendChild($number_of_matches_text);   $books_dom->appendChild($match); $books_dom->appendChild($number_of_matches); $xmlString=$dom->saveXML(); echo $xmlString; ?> [/code]
×
×
  • 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.