[SOLVED] Search results like these (link)

This is a discussion on "[SOLVED] Search results like these (link)" within the PHP Forum section. This forum, and the thread "[SOLVED] Search results like these (link) are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 27th, 2008, 16:33
Junior Member
Join Date: Jan 2008
Location: Reykjavik
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Search results like these (link)

** EDIT**
Skip to post #3

I´m looking to build a search results PHP like this one, but I wouldn't know where to start. I would like my results to display in a simple yet elegant manner (like in the link).

1. [Species name]
[Species description................]

2. etc....

Species name from tableX_Column2 and species description from tableX_column3. (Column1 (is primary, auto increment).

**EDIT**
I've erased most part of my original post as is was to much/complicated.
See post #3 for a more concise post

Last edited by skuliaxe; Jan 27th, 2008 at 21:02.
Reply With Quote

  #2 (permalink)  
Old Jan 27th, 2008, 19:08
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search results like these (link)

Sorry, it's just too much work to read through the entire code. However, if I'm correctly following what you have and what you want, it's just a matter of applying the correct html/css tags within the section you want to style. Like in
PHP: Select all

// now you can display the results returned
  
while ($rowmysql_fetch_array($result)) {
  
$title $row["1st_field"];

  echo 
"$count.) $title" ;
  
$count++ ;
  } 
You might have something like:
PHP: Select all

// now you can display the results returned
  
while ($rowmysql_fetch_array($result)) {
  
$title $row["1st_field"];

  echo 
"$count.)&nbsp;<div class='resulthead'>$title</div>" ;
  
$count++ ;
  } 
I hope that helps a little.
Reply With Quote
  #3 (permalink)  
Old Jan 27th, 2008, 20:56
Junior Member
Join Date: Jan 2008
Location: Reykjavik
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search results like these (link)

Thanks for that.
What I can´t seem to figure out (due to extreme lack of knowledge ) is th following:

Currently I´m using:
[SELECT * FROM table WHERE column LIKE (searchstring)...]

Could I use instead:
[SELECT id FROM table WHERE column LIKE (searchsting)...]
$id=mysql_query($query);
(Where 'id' is the Primary key and an auto increment for that field)

If that is OK then I don´t know how to echo/Print something like this:

echo [The 'name' from $id in database] <-- Looks up the 'id' field and fetches/prints data from the 'name' column in the field = $id.
echo [The 'description' from $id in database] <-- Looks up the 'id' field and fetches/prints data from the 'descriptions' column in the field = $id.

THAT IN A WHILE LOOP, while there is a result, echo/print that information.
That is what i´m trying to do here Any basic help or nudge in the right direction would make me really happy

Last edited by skuliaxe; Jan 27th, 2008 at 21:04.
Reply With Quote
  #4 (permalink)  
Old Jan 28th, 2008, 04:41
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Search results like these (link)

If you want to output everything in the database, then use "SELECT *":
PHP: Select all

$query=mysql_query("SELECT * FROM table");
while(
$row=mysql_fetch_array($query,MYSQL_ASSOC)) {
    echo(
'<h1>'.$row['name'].'</h1>');
    echo(
'<p>'.$row['description'].'</p>');

If you just want the row with a specific id, then add a WHERE:
PHP: Select all

$query=mysql_query("SELECT * FROM table WHERE id='$id'");
while(
$row=mysql_fetch_array($query,MYSQL_ASSOC)) {
    echo(
'<h1>'.$row['name'].'</h1>');
    echo(
'<p>'.$row['description'].'</p>');

If this isn't what you want, then, sorry... I hope I'm understanding your question, masonbarge also posted a similar solution.....
Reply With Quote
  #5 (permalink)  
Old Jan 28th, 2008, 11:28
Junior Member
Join Date: Jan 2008
Location: Reykjavik
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search results like these (link)

[SOLVED]
Thank you so much masonbarge and c010depunkk (cookies )

I ended with the following:
PHP: Select all

$query "SELECT * FROM table WHERE column1 LIKE \"%$trimmed%\" ORDER BY column1";

 
$numresults=mysql_query($query);
 
$numrows=mysql_num_rows($numresults); 
And then show results:
PHP: Select all

while ($rowmysql_fetch_array($result)) {
  
$column1 $row["column1"];
  
$column2 $row["column2"];

   echo 
"$count.)&nbsp; $column1 &nbsp;&nbsp;&nbsp; $column2" ;
  
$count++ ; 
Now I just have to do edit the 'echo' so it displays the results in a more elegant manner
Thanks again
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlinking PHP/SQL search results andrwleong PHP Forum 9 Mar 26th, 2008 16:09
[SOLVED] Displaying search results on a different page longstand PHP Forum 4 Nov 19th, 2007 22:26
search results with servlet or JSP twix_ Other Programming Languages 1 Nov 2nd, 2006 21:25
Index Server search results problem starrbuck Classic ASP 0 Feb 22nd, 2006 17:20


All times are GMT. The time now is 05:54.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43