Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/183811-include-a-php/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/183811-include-a-php/#findComment-970981
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/183811-include-a-php/#findComment-971647
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/183811-include-a-php/#findComment-971711
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/183811-include-a-php/#findComment-973021
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.