Jump to content

Archived

This topic is now archived and is closed to further replies.

Lynk

simple table search!

Recommended Posts

[font=tahoma]i wrote this little thingie, when i move the [b]echo[/b] part, out of the [b]if (){ }[/b] part way below,
it works, but i just cant seem to get it working with the [b]if[/b]....[/font]

anyone?

[code]<? function select5(){
$select5 = "SELECT * FROM lynk_fm WHERE artist LIKE '%$q%' ORDER BY id $sort";
$obj5 = mysql_query($select5) or die($MySQLError.mysql_error());
return $obj5; } ?>

<form action="<?=$PHP_SELF?>" name="form_search">
<table width="100%" style="border:1px dashed darkgray;">
<tr>  <td width="222" bgcolor="#EEEEEE">Music search</td></tr>
<tr><td valign="top"><input name="q" type="text" class="INPUT" onFocus="if(this.value=='Tiesto')this.value='';" value="Tiesto">
<select name="sort" class="I_send">
  <option value="DESC">Newest first</option>
  <option value="ASC">Oldest first</option>
</select>
<input type="submit" class="I_send" value="Go >"> Search for music on Lynk Fm <br />
</td></tr></table>
</form>

<? if($_POST['q'] != "") {?>

<? $res5 = select5(); while($row5 = mysql_fetch_object($res5)) { echo "$row5->song<br>"; } ?>

<? } ?>[/code]

Share this post


Link to post
Share on other sites
Try this:

[code]<?php
function select5($q,$sort){
$select5 = "SELECT * FROM lynk_fm WHERE artist LIKE '%$q%' ORDER BY id $sort";
$obj5 = mysql_query($select5) or die($MySQLError.mysql_error());
return $obj5;
}

if($_POST['q'] != "") {
$res5 = select5($_POST['q'],$_POST['sort']);
while($row5 = mysql_fetch_object($res5)){
echo "$row5->song<br>";
}
?>

<form action="<?=$PHP_SELF?>" name="form_search">
<table width="100%" style="border:1px dashed darkgray;">
<tr>  <td width="222" bgcolor="#EEEEEE">Music search</td></tr>
<tr><td valign="top"><input name="q" type="text" class="INPUT" onFocus="if(this.value=='Tiesto')this.value='';" value="Tiesto">
<select name="sort" class="I_send">
  <option value="DESC">Newest first</option>
  <option value="ASC">Oldest first</option>
</select>
<input type="submit" name="submit" class="I_send" value="Go >"> Search for music on Lynk Fm <br />
</td></tr></table>
</form>[/code]

Orio.

Share this post


Link to post
Share on other sites
no man, still nothing...the page just loads quickly, and the url shows this

http://lynkonline.atlas2wielers.nl/lynk_fm/lynk_fm2.php?q=Tiesto&sort=DESC&submit=Go+%3E

Share this post


Link to post
Share on other sites
[quote author=Lynk link=topic=104462.msg416700#msg416700 date=1155720253]
now it shows everything with tiesto in it...
regardeless of the form...


[/quote]no wait, it shows everything

Share this post


Link to post
Share on other sites
anyway, im really stuck this time...

i just know its probably something soo silly...

Share this post


Link to post
Share on other sites
well it is not silly. You just don't know. You need something like this
[code]
<?php
if (isset($_POST['submit'])) {
  //preform your code here
}
?>
<!--html here-->
[/code]

Share this post


Link to post
Share on other sites
[quote author=tomfmason link=topic=104462.msg416707#msg416707 date=1155720838]
well it is not silly. You just don't know. You need something like this
[code]
<?php
if (isset($_POST['submit'])) {
  //preform your code here
}
?>
<!--html here-->
[/code]
[/quote]

i actually do know, i DID have that the first time, that didnt work, so i switched to something more simpler...
but i but it back now, you can check it here: http://lynkonline.atlas2wielers.nl/lynk_fm/lynk_fm2.php

Share this post


Link to post
Share on other sites
Sorry if I offended you. Anyways give this a try

[code]
<?php
if (isset($_POST['submit'])) {
    $q = mysql_real_escape_string(trim($_POST['q']));
    $sort = mysql_real_escape_string(trim($_POST['sort']));
    if ((!$q) || (!$sort)) {
        echo "You did not submit a required field";
        exit(1);
  }
   $select5 = "SELECT * FROM lynk_fm WHERE artist LIKE '%$q%' ORDER BY id $sort";
   $obj5 = mysql_query($select5) or die(mysql_error());

   while($row5 = mysql_fetch_assoc($obj5)){
          echo '' . $row5['song'] . '<br />';
   }
}
?>

<form action="<?=$PHP_SELF?>" name="form_search">
<table width="100%" style="border:1px dashed darkgray;">
<tr>  <td width="222" bgcolor="#EEEEEE">Music search</td></tr>
<tr><td valign="top"><input name="q" type="text" class="INPUT" onFocus="if(this.value=='Tiesto')this.value='';" value="Tiesto">
<select name="sort" class="I_send">
  <option value="DESC">Newest first</option>
  <option value="ASC">Oldest first</option>
</select>
<input type="submit" name="submit" class="I_send" value="Go >"> Search for music on Lynk Fm <br />
</td></tr></table>
</form>[/code]

Share this post


Link to post
Share on other sites
no  ;) i wasnt offended, i really appreciate the help, let me give this a try :D


edit: no, still nothing  :'(  :'(  :'(  :'(  here is the EXACT code i used...

[code]
<?php include ('../nect.php');?>
<?php
if (isset($_POST['submit'])) {
    $q = mysql_real_escape_string(trim($_POST['q']));
    $sort = mysql_real_escape_string(trim($_POST['sort']));
    if ((!$q) || (!$sort)) {
         echo "You did not submit a required field";
        exit(1);
   }
   $select5 = "SELECT * FROM lynk_fm WHERE artist LIKE '%$q%' ORDER BY id $sort";
   $obj5 = mysql_query($select5) or die(mysql_error());

   while($row5 = mysql_fetch_assoc($obj5)){
          echo '' . $row5['song'] . '<br />';
   }
}
?>

<form action="<?=$PHP_SELF?>" name="form_search">
<table width="100%" style="border:1px dashed darkgray;">
<tr>  <td width="222" bgcolor="#EEEEEE">Music search</td></tr>
<tr><td valign="top"><input name="q" type="text" class="INPUT" onFocus="if(this.value=='Tiesto')this.value='';" value="Tiesto">
<select name="sort" class="I_send">
  <option value="DESC">Newest first</option>
  <option value="ASC">Oldest first</option>
</select>
<input type="submit" name="submit" class="I_send" value="Go >"> Search for music on Lynk Fm <br />
</td></tr></table>
</form>
[/code]

Share this post


Link to post
Share on other sites
i just dont get it, the page must not like me or something,  :P cuz all the other pages work fine ;D

anyway, im tring to get this fixed for my [url=http://lynkonline.atlas2wielers.nl/preloader.php]still in beta site[/url]

Share this post


Link to post
Share on other sites

×

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.