SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need a little help on search script

    Newbie trying to make a little search script to search a field by text and then present the row/s. The script below is returning only the field according to the search and not the whole row. Any help appreciated.

    //Connect to database server
    $table = $db->prefix("fishdiary");

    if($_POST["submit"])
    {
    $fish = $_POST["caught"];
    $query = "SELECT * FROM $table WHERE caught = '$fish'";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result))
    {
    {
    $content .= "
    <table border='1' cellpadding='4' cellspacing='0' style='border-collapse: collapse' align=center bordercolor='#FFFFFF' width='90%'>

    <tr>
    <td width='100%' colspan='4' align=center><u><b><font color=darkblue size=2>Submitted by <a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&amp;to_userid=".$uid."', 'pmlite', 450, 380);\"><u>".$uname."</u></a> on the ".showdate($date)."</font></b></u></td>
    </tr>
    <tr>
    <td width='50%' colspan='2' align=center bgcolor=B3D6F2><u>Last New Moon:</u> <b>".$newmoon."</b></td>
    <td width='50%' colspan='2' align=center bgcolor=B3D6F2><u>Days after last New Moon:</u> <b>".$moonday."</b></td>
    </tr>
    <tr>
    <td width='30%' bgcolor=EAFBFD><u>Started Fishing:</u> <b>".$beginfishtime."</b></td>
    <td width='40%' colspan='2' bgcolor=EAFBFD><u>Start Fishing Tide:</u> <b>".$beginfishtide."</b></td>
    <td width='30%' bgcolor=EAFBFD><u>Temperature:</u> <b>".$peaktemp."</b></td>
    </tr>
    <tr>
    <td width='30%' bgcolor=EAFBFD><u>Stopped Fishing:</u> <b>".$stopfishtime."</b></td>
    <td width='40%' colspan='2' bgcolor=EAFBFD><u>Stop Fishing Tide:</u> <b>".$stopfishtide."</b></td>
    <td width='30%' bgcolor=EAFBFD><u>Water Temperature:</u> <b>".$watertemp."</b></td>
    </tr>
    <tr>
    <td width='30%' bgcolor=EAFBFD><u>Best Fishing Time:</u> <b>".$bestfishtime."</b></td>
    <td width='40%' colspan='2' bgcolor=EAFBFD><u>Peak Fishing Tide:</u> <b>".$bestfishtide."</b></td>
    <td width='30%' bgcolor=EAFBFD><u>Barometer:</u> <b>".$barometer."</b></td>
    </tr>
    <tr>
    <td width='50%' colspan='2' align=center bgcolor=B3D6F2><u>Fish Targetted:</u> <b>".$target."</b></td>
    <td width='50%' colspan='2' align=center bgcolor=B3D6F2><u>Fish Caught:</u> <b>".$caught."</b></td>
    </tr>
    <tr>
    <td width='100%' colspan='4' bgcolor=D0FBFD><u>Location:</u><br>
    <b>".$location."</b></td>
    </tr>
    <tr>
    <td width='100%' colspan='4' bgcolor=D0FBFD><u>Successful Bait:</u><br>
    <b>".$bait."</b></td>
    </tr>
    <tr>
    <td width='100%' colspan='4' bgcolor=D0FBFD><u>Details of Trip:</u><br>
    <b>".$details."</b></td>
    <tr>
    <td width='100%' colspan='4'>&nbsp;<hr></td>
    </tr>
    </tr>";
    }
    $content .= "</table>";


    themecenterbox_center($title, $content);
    }
    }

  2. #2
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try print_r($result); and see wot it gives you.

  3. #3
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just gives me this back:
    Resource id #63

  4. #4
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    print_r($row) inside the loop n tell me wot it gives
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  5. #5
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see some problems with your use of double quotes, for example, this statement:
    Code:
    <td width='100%' colspan='4' align=center><u><b><font color=darkblue size=2>Submitted by <a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&amp;to_userid=".$uid."', 'pmlite', 450, 380);\"><u>".$uname."</u></a> on the ".showdate($date)."</font></b></u></td>
    If I read your code correctly, this should be part of the value for:
    Code:
    $content .= "
    blah blah
    Change those double quotes to single quotes, or &quot; and I think it will fix your problem.

    <added>
    View source for the page and see what the HTML shows, too. That might also be a clue for where the problem is.
    </added>
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  6. #6
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Devscripts,

    print_r($row);
    returns this

    Array ( [0] => 2 [id] => 2 [1] => 2 [uid] => 2 [2] => Larry Hall [uname] => Larry Hall [3] => 1094019962 [date] => 1094019962 [4] => 5 [newmoon] => 5 [5] => 5 [moonday] => 5 [6] => 6:00am [beginfishtime] => 6:00am [7] => 6:00pm [stopfishtime] => 6:00pm [8] => 7:00am [bestfishtime] => 7:00am [9] => First of the incoming [beginfishtide] => First of the incoming [10] => Midway through outgoing [stopfishtide] => Midway through outgoing [11] => Last of the incoming [bestfishtide] => Last of the incoming [12] => 32 [peaktemp] => 32 [13] => 27 [watertemp] => 27 [14] => High [barometer] => High [15] => Pelagic [target] => Pelagic [16] => Trevally [caught] => Trevally [17] => Around the north end of Palm Island [location] => Around the north end of Palm Island [18] => Lure [bait] => Lure [19] => It was a hot bite earlier in the morning but it petered out as the day heated up. We stopped and bottom bashed for a while on a small patch of reef but only caught undersized fish. On the way home we cast poppers to queensfish for a couple of 1 meter fish [details] => It was a hot bite earlier in the morning but it petered out as the day heated up. We stopped and bottom bashed for a while on a small patch of reef but only caught undersized fish. On the way home we cast poppers to queensfish for a couple of 1 meter fish )
    This appears to be the row according to the search but I am not sure how I get this info to appear in my ($content .=) section. It only shows the ".$caught." part

    Vinyl-Junkie,
    Shall have a look at those quotes but I don't think that is the cause of my probs. That whole $content .=" works ok in another page and appears to work ok in this page. I think it is something about returning the $row
    Thanks

  7. #7
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    accodring to your code you are not echoing the arrays in terms of $row['fieldname']; i see you have done this....
    <td width='100%' colspan='4' align=center><u><b><font color=darkblue size=2>Submitted by <a href=\"javascriptpenWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&amp;to_userid=".$uid."', 'pmlite', 450, 380);\"><u>".$uname."</u></a> on the ".showdate($date)."</font></b></u></td>

    an example $uname is a field name?

    i quote u "Quote:
    Array ( [0] => 2 [id] => 2 [1] => 2 [uid] => 2 [2] => Larry Hall [uname] => Larry Hall [3] => 1094019962 [date] => 1094019962 [4] => 5 [newmoon] => 5 [5] => 5 [moonday] => 5 [6] => 6:00am" the names here according to ur query change all ur $identifiers to $row['fieldname'];

    example echo $row['uid'];
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)

  8. #8
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot devscripts, I have got it now.

  9. #9
    SitePoint Zealot devscripts's Avatar
    Join Date
    Sep 2004
    Location
    ur monitor
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "None of you [truly] believes until he wishes for his brother what he wishes for himself." By The one and Only Prophet Mohammed (Peace and blessings be upon him)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •