MudiW Posted December 3, 2009 Share Posted December 3, 2009 Hello, I'm trying to include a function that shows the recent searches. Example I have index.html ------------------------------------------------------------------------ - - - Info info - - - - and here I want to include the recent searches page - - Recent searches(searches.php) - - 1 2 - - 3 4 - ------------------------------------------------------------------------ But I have no clue on how to do it, I tried include and the file location etc, but I get something of mailer.php in line 3. ALSO, I want to make it on the recent search appear 2 searches per line. Example I have mysql_query("SELECT * FROM tags ORDER by id DESC LIMIT 24"); I want to appear First Search Second search Third Search Fourth Search Fifth search And so on. ANY help is appreciated, any clue, tried google several times, Thanks BEST REGARDS Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted December 3, 2009 Share Posted December 3, 2009 post the exact error you get Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 4, 2009 Author Share Posted December 4, 2009 I got the include working. It was a problem with my code. How do I make the mysql appear 2 in 1 line, another 2 in 1 line, etc. Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted December 4, 2009 Share Posted December 4, 2009 oh like a table, something like echo '<table border="1"><tr>'; $count = 1; while($row = mysql_fetch_array($query)){ echo "<td>".$row['column']."</td>"; if ($count % 2 == 0){ echo "</tr><tr>"; } $count++; } if ($count %2 == 0){ echo "</tr>"; } echo "</table>"; should work Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 5, 2009 Author Share Posted December 5, 2009 Doesn't work :S. This is the whole code <?php include "session.php"; ?> <link rel="stylesheet" href="<?=$web_path?>css/music.css" media="screen,projection" type="text/css" /> <div align="center"> <div class="tag-box"> <b>Recent Searches:</b> <?php if($type=="lyrics") { $type = "lyrics"; } elseif($type=="video") { $type = "video"; } else { $type = "mp3"; } $q4 = mysql_query("SELECT * FROM tags ORDER by id DESC LIMIT 25"); $i = 1; while($tags = mysql_fetch_array($q4)) { $tag = $tags[tag]; $tag = str_replace(" ","-",$tag); if(($type=="lyrics")||($type=="video")) { $tag = str_replace("-","+",$tag); } $tag_name = $tags[tag]; $tag_name = ucwords($tag_name); $count = $i++; if(($count==1) || ($count==5) || ($count==10) || ($count==15) || ($count==20)) { $class = "style1"; } elseif(($count==3) || ($count==9) || ($count==14) || ($count==16) || ($count==18)) { $class = "style2"; } elseif(($count==2) || ($count==7) || ($count==12) || ($count==17) || ($count==19)) { $class = "style3"; } elseif(($count==4) || ($count==11) || ($count==13) || ($count==6) || ($count==15)) { $class = "style4"; } ?> <a class="<?=$class?>" href="<?=$web_path?>search/<?=$tag?>/1/<?=$type?>"><?=$tag_name?></a> ERROR Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mudiw/public_html/mudiw.com/mp3/includes/recent-searches.php on line 9 THANKS Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted December 5, 2009 Share Posted December 5, 2009 that probably means your query failed. add or trigger_error(mysql_error()); right after your query (on the same line) and see if you get a more useful error Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 5, 2009 Author Share Posted December 5, 2009 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mudiw/public_html/mudiw.com/mp3/includes/recent-searches.php on line 8 I guess I have to write order by fields or something. I have 3 fields. Thanks, and sorry for my noob code in php. I just need a small modification Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 7, 2009 Author Share Posted December 7, 2009 Bump, I really need help. Quote Link to comment Share on other sites More sharing options...
premiso Posted December 7, 2009 Share Posted December 7, 2009 I do not see where you are connecting to mysql and selecting the database? Are you connecting and selecting the DB? As for mike's suggestion he meant this: $q4 = mysql_query("SELECT * FROM tags ORDER by id DESC LIMIT 25") or trigger_error("Query Failed: " . mysql_error()); See if that triggers an error, if so what is it. If you are not connecting to MySQL, well you have to be connected for it to work. Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 9, 2009 Author Share Posted December 9, 2009 $count = 1; while($row = mysql_fetch_array ($query)or trigger_error(mysql_error()){ I know is bad arranged, but I don't know how to put it. Thanks Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 10, 2009 Author Share Posted December 10, 2009 Another BUMP :S Omg Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted December 10, 2009 Share Posted December 10, 2009 premiso wrote it right out for you. change out your existing: $q4 = mysql_query("SELECT * FROM tags ORDER by id DESC LIMIT 25"); for what he gave you. Quote Link to comment Share on other sites More sharing options...
MudiW Posted December 10, 2009 Author Share Posted December 10, 2009 Ups wasn't like that when I saw it. http://pastie.org/737858 Parse error: syntax error, unexpected $end in /home/mudiw/public_html/mudiw.com/mp3/includes/recent-searches.php on line 43 THANKS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.