-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Posts posted by doddsey_65
-
-
Paste the actual code you're using. That doesn't appear to be it.
sorry i fixed it, instead of
$sql = "SELECT * FROM '".TBL_PARENTS."'" or die(mysql_error());
i used:
$sql = "SELECT * FROM ".DB_PREFIX."parents" or die(mysql_error());
-
i have the following sql running on local but i get an error.
the sql:
$sql = "SELECT * FROM '".TBL_PARENTS."'" or die(mysql_error());
the config file:
define('DB_PREFIX', 'forum_'); define('TBL_PARENTS', DB_PREFIX.'parents');
the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''forum_parents'' at line 1
the echoed sql:
SELECT * FROM 'forum_parents'
as you can see when it is echoed it looks fine. Any ideas? The server im using is wamp server.
-
the following is the code for my homepage (WIP) and the 2nd page which is displayed via get. however when the second page is displayed the ifrst one is displayed under neath and nothing displays on the first page. This is usually solved via a elseif or else which i have included but it still isnt working.
<?php include 'includes/header.php'; include 'config/config.php'; # When displaying the list of topics # if (isset($_GET['forum'])) { $forumid = $_GET['forum']; ?> <div id="content_holder"> <table id="forum_table"> <tr> <td id="forum_name">Topic</td> <td id="forum_count">Replies</td> <td id="forum_count">Views</td> <td id="forum_stats">Last Post</td> <?php $sql = mysql_query(" SELECT * FROM $tbl_topics WHERE forum_id = $forumid") or die (mysql_error()); while($row = mysql_fetch_object($sql)) { echo '<tr><td id="forum_name"><p>' . $row->topic_name . '</p><p>' . $row->topic_poster . '</p></td><td id="forum_count"><p>' . $row->topic_replies . '</p></td><td id="forum_count"><p>' . $row->topic_views . '</p></td><td id="forum_stats"><p>'; if (!$row->topic_last_poster) { echo 'No Replies'; } else { echo $row->topic_last_poster . '</p><p>' . date("F j, Y, g:i a", strtotime($row->topic_last_post_time)); } echo '</p></td></tr>'; } ?> </table> </div> <? } else { ?> <!-- When displaying the home page (list of forums) --> <div id="content_holder"> <table id="forum_table"> <tr> <td id="forum_name">Forum</td> <td id="forum_count">Topics</td> <td id="forum_count">Posts</td> <td id="forum_stats">Last Post</td> <?php $sql = mysql_query("SELECT * FROM $tbl_forums") or die (mysql_error()); while($row = mysql_fetch_object($sql)) { echo '<tr><td id="forum_name"><p> <a href="index.php?forum=' . $row->forum_id . '">' . $row->forum_name . '</a></p><p>' . $row->forum_description . '</p></td><td id="forum_count"><p>' . $row->forum_topics . '</p></td><td id="forum_count"><p>' . $row->forum_posts . '</p></td><td id="forum_stats"><p>'; if (!$row->forum_last_poster) { echo 'No Posts'; } else { echo $row->forum_last_poster . '</p><p>' . date("F j, Y, g:i a", strtotime($row->forum_last_post_time)); } echo '</p></td></tr>'; } ?> </table> </div> <?php } ?>
-
hopefully you will be kind enough to add my tables into that code as i have never used joins before.
table:
forum_posts
rows
forum_posts.forumid -> the id of the forum so i know which forum the post belongs to
forum_posts.postedby -> holds the username
-
top search if something is like the entered term do
"SELECT * FROM table WHERE row LIKE %'".$_POST[search_term']."'%"
-
How would i get it so i can show the most active forum the user has posts in. I have a posts table which lists the posts aswell as the forum they are in by id. So how would i select all of the posts with their username(easy) but then from these results calculate which id shows up the most so i can echo that?
-
thanks but its not quite what im looking for. I have my combo box and when the user selects an item from it it will display some text along side the box in a div or something.
-
Hi, basically i want it so that when the user selects a value from a drop down list a small peice of text appears next to it describing what they have selected. I dont know what words to put into google so does anyone have any links or can help?
-
Whenever i make a website it appears to load slowly compared to others. Could this be because i always use select all in my sqls? would SELECT 1, 2 be better for speed than SELECT *?
-
any ideas?
-
it works, sort of, the 1st group is displayed again under the second group. And i know my code is always a mess lol
-
thanks, i tried yours but i couldnt get it to work. heres what i have now:
$sql = mysql_query("SELECT * FROM forum_groups") or die (mysql_error()); while ($row = mysql_fetch_object($sql)) { $groupid = $row->groupid; $forumid2 = $row->forumid; $groupname = $row->groupname; } echo ' <td class="forum-left">'.$groupname.'</td> <td class="forum-middle">Topics</td> <td class="forum-middle">Posts</td> <td class="forum-right">Last Post</td></tr>'; $sql = mysql_query("SELECT * FROM $forums WHERE groupid = $groupid") or die (mysql_error()); while ($row = mysql_fetch_object($sql)) { echo '<tr><td class="forum2"> <a href="index.php?f='.$row->id.'">' . $row->name . '</a><br /> <h4 style="font-size:10px;">'.$row->description.'</h4> </td><td class="forum">'; $id = $row->id; $sql2 = mysql_query("SELECT * FROM $threads WHERE forumid = '$id'") or die (mysql_error()); $num = mysql_num_rows($sql2); echo $num . '</td><td class="forum">'; $sql3 = mysql_query("SELECT * FROM forum_posts WHERE forumid = '$id'") or die (mysql_error()); $num2 = mysql_num_rows($sql3); echo $num2 . '</td><td class="forum">'; echo 'By '.$row->lastpost.' <h5 style="font-size: 10px;">On '; echo date("F j, Y, g:i a", strtotime($row->date)); echo '</h5></td></tr><tr>'; }
there are currently 2 items in group 1 and 1 in group 2. This displays the stuff in group 1 properly but doesnt display stuff from group 2 under it as i had hoped.
-
my mind has drawn a blank so i need help.
look here http://thevault.cz.cc/forum/index.php for a better look.
Im making a forum and i have 4 database tables: groups, forums, threads, and posts
all i want to do is show the forums on the home page categorized by which group they are in like normal forums do.
ie the forums belonging to group NEWS will display together with the news header at the top of the table
and then the different groups under that with their own table headers.
Sounded simple enough to me but i cant do it. When i try it just displays a header above each forum rather than a header at the top of the forums in a group. Hope this makes sense.
-
but the id in the details table is different from the id in the post table since the details id is for the users and the post id is the id for the posts. So a join wouldnt work with 2 different id values would it?
-
the post is in forum_posts.content
the author is in posts.author
the user signature is in details.signature
i echo the post by pulling all posts from the database
i then echo who the author is
i then want to echo the sig by doing something like
echo $post
echo $sig WHERE author= $_SESSION['usr']
something like that?
-
thanks, now i understand that this isnt what i need lol.
More info:
I have 2 tables: forum_posts and details
i need to pull everything from forum_posts and i need to pull signature row from details. How would i do this? it cant be a join because there are no identical tables.
-
i tried this but i dont get any results:
$sql = mysql_query(" SELECT forum_posts.content, forum_posts.postedby, forum_posts.postedby, details.signature FROM forum_posts INNER JOIN details on forum_posts.content = details.signature WHERE forum_posts.topicid = '$threadid'") or die (mysql_error());
-
so how would i change mine to match yours? sorry but this is the first time i have used join. I tried and i get an error not unique table
-
im using the following query to pull all rows from forum_posts and the signature row from a table called details.
Only problem is that the signature doesnt show up and the posts are repeated several times. What have i done wrong?
$sql = mysql_query(" SELECT * FROM forum_posts p, details d WHERE p.topicid = '$threadid'") or die (mysql_error()); while ($row = mysql_fetch_object($sql)) { $topicname = $row->topicname; $topicnamesafe = str_replace(" ", "-", $topicname); $sig = $row->signature; echo '<tr><td class="posts" style="width:80%;">' .$row->content . '<hr />'.$sig.'</td><td class="forum">'; echo 'By ' . $row->postedby . '<br /><h5 style="font-size: 12px;">On '; echo date("F j, Y, g:i a", strtotime($row->date)); echo '</h5></td></tr><tr>'; }
-
okay i have a htaccess file which reqrites
profile.php?username=username
to
profile/username/username.html
Do i now need my href links to point to the second url instead of the dynamic one?
I have done this and it loads the page profile/usewrname/username.html but the information
i am supposed to get from $_GET['username'] doesnt show up and its just a blank section.
-
nope neither of them worked either. just to make sure im putting it in the right place the .htaccess file is in the same directory as the main index.php page.
-
I am trying to use a htaccess file to rewrite my urls to be SEO friendly.
eg instead of profile.php?username=username
it would be profile/username/username.html
this is the contents of my htaccess:
Options +FollowSymLinks RewriteEngine on RewriteRule profile/usrename/(.*)/ profile.php?usrename=$1
unfortunatly its not working. My host does have this enabled and it is in my site root. Is there anything i have forgot to include for it to work?
-
Use $_SERVER['DOCUMENT_ROOT'] to form absolute file system paths -
include $_SERVER['DOCUMENT_ROOT'] . '\includes\header.php';
i added that line but still nothing, is there something else i need to do?
-
I have 4 files which i include into every file. These are header.php, db.php, sidebar.php and footer.php.
It works like a dream, but i have changed the file layout. It used to be htdocs/myaccount.php
and in myaccount.php i would use include('includes/header.php'); which also worked. However now i have moved myaccount.php to myaccount/index.php. What do i need to do to make the includes work? ive tried ../ and ../../ and ./ but none of them work, i keep getting a syntax error(500). Heres my directory list
Root
includes header.php db.php sidebar.php footer.php
myaccount index.php
text formatting
in PHP Coding Help
Posted
I want a little online users list at the bottom of my page and the color of the username is to match the color defined in the database. but how do i get them to align side by side? if i add them to a <p> they will all appear under neath each other. Heres my current code:
also i want a comma at the end of each but how do i stop it adding a comma to the end of the last one?