Jump to content

Alura

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    Texas

Alura's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm working on a similar issue, and am trying to use a JOIN clause for my page. Here's an example from W3Schools: SELECT column_name(s) FROM table_name1 JOIN table_name2 ON table_name1.column_name=table_name2.column_name http://w3schools.com/sql/sql_join.asp I'm having issues with getting my JOIN to work, but from what you've said, it looks like you might need to see about using that and then SORT by code to get what you want. Sorry this wasn't much help - hope you're able to get it to work.
  2. Thanks. That seemed to be the bit I needed to fix up. Unfortunately, my results display page is acting up now. Win one, lose one. At least it's Friday, and I'll probably figure it out over the weekend. Thanks for the help.
  3. Hi - I am in the same boat at the moment, and wondered if you found out how to add your link to the search form. I just posted a similar request, and wanted to ask if you figured it out, may I see how you did it? If you haven't, and if I get any responses, I'll post them back on here so you can see if they solve your problem. Thanks!
  4. Hello - I'm new to PHP and I am working on a database to display information about various species of snakes, and eventually want to progress to information about each individual snake in our collection at my workplace. As I'm getting used to PHP, I've decided to concentrate on just simple species information before tackling the larger project. I set up the DB in MAMP and have created a simple PHP navigation page with a table linked to the DB that works fine for people browsing species, and it is set up to take them to a display page set up to show the specific species clicked from the table with this code on the "VIEW" link: <a href="species_display.php?Scientific=<?php echo $row_specieslist['Scientific_Name']; ?>">view</a> My table is called "specieslist", and my URL parameter is "Scientific", and the results page is "species_display.php". I set this up via Dreamweaver's toolboxes. Since we have over 35 species (and can go up to 300), I have been working on a search option for my site as well, and while it will return the desired results in a table, I am unsure as to how to add the above 'VIEW" Link to the tabled results. I've tried modifications of the above link code, but have been unsuccessful as yet in getting it to work. Am I even on the right track? Here is my search page, created after following some online tutorials and tweaked with advice from this forum: <HTML> <head> <title>Snakebook Search Engine</title> </head> <body> <form action='search.php' method='GET'> <p><img src="images/Snakebook-Logo.png" width="311" height="83" /> <input type='text' size='50' name='search' /> </p> <p> <input type='submit' name='submit' value='Search' /> </p> </center> </font> </form> </body> </HTML> [code=php:0] <?php //get data $button = $_GET['submit']; $search = $_GET['search']; if (!$button) echo "You didn't submit a keyword."; else { if (strlen($search)<=2) echo "Search not valid. Search term too short."; else { echo "You searched for <b>$search</b> <hr size='1'>"; //connect to our database mysql_connect("localhost:8889","root","root") or die ('Error connecting'); mysql_select_db("snakebook"); { //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) $construct .="Scientific_Name LIKE '%$search_each%' OR Common_Name LIKE '%$search_each%' OR Physical_Characteristics LIKE '%$search_each%' OR Geographic_Range LIKE '%$search_each%' OR Diet LIKE '%$search_each%' OR Venom LIKE '%$search_each%' OR Habitat LIKE '%$search_each%' OR Notes LIKE '%$search_each%' "; else $construct .=" OR Scientific_Name '%$search_each%' OR Common_Name LIKE '%$search_each%' OR Physical_Characteristics LIKE '%$search_each%' OR Geographic_Range LIKE '%$search_each%' OR Diet LIKE '%$search_each%' OR Venom LIKE '%$search_each%' OR Habitat LIKE '%$search_each%' OR Notes LIKE '%$search_each%' "; } //echo out construct $construct = "SELECT * FROM specieslist WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "No results found."; else { echo "<b>$foundnum</b> result(s) found.<p><hr size='1'>"; while ($runrows = mysql_fetch_assoc($run)) { //get data to display echo "<center><table border='0' cellpadding='5' cellspacing='0'> " ; $common = $runrows['Common_Name']; $scientific = $runrows['Scientific_Name']; $thumbnail = $runrows['Thumbnail']; //display data echo "<tr> <td><strong>$thumbnail</strong></td> <td><strong><i>$scientific</i></strong></td> <td><strong>$common</strong></td> <td><strong>$view</strong></td> </tr>" ; } } } } } ?> [/code] I apologize for any weird spacing or sloppy coding - I'm still learning the correct way to write all of this. Any help is appreciated, Thanks!
×
×
  • 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.