
id
Members-
Posts
37 -
Joined
-
Last visited
Everything posted by id
-
So are you suggesting that i do not use cookies?
-
Ok, this is my question: What is the best way to change the theme of a site (coding wise)? Example, if the users wants to a certain theme, then an option would come up to pick their theme. However, another user wont get the theme change (just like IPB). How would i code that option? 1. Would i have to code the css in php... So instead of style.css it will be style.php 2. On the settings file, it will have an option for the user to pick a theme using a dropdown menu . So if the user selects the all red background, then $default_css = $_POST["theme_selection"]; 3. <link rel=StyleSheet href="<?php $default_css; ?> " type="text/css" /> or is their a simplier way and or a smarter way of achieving this?
-
2012-08-11 00:32:42 18 1 2012-08-11 00:35:25 18 2 2012-08-11 00:35:44 18 3 2012-08-11 00:37:01 18 4 2012-08-11 00:38:34 14 5 2012-08-11 00:39:45 14 6 2012-08-11 00:45:28 6 7 2012-08-11 01:07:29 20 8 2012-08-11 10:34:21 18 9 2012-08-11 10:35:47 13 10 2012-08-11 10:36:08 19 11 2012-08-11 10:36:49 18 12 2012-08-11 10:37:12 6 13 2012-08-11 10:57:27 20 14
-
Does the members table have an id field? If so, you should be using that instead of the username. And what is "forum_replies" - is that the number of "forum_answer"'s associated with the forum post? And, I'm not understandin this Are you trying to update a value in the user's table when they make a post? If so, you are doing this completely wrong. You should really go back and read some tutorials on databases. You can very easily get a users post count by JOINing the posts table on the user table and having the database do the calculation for you. Here is an example of a query to return each user along with their associated post count from a properly structured DB. The table/field names are not specific to your structure. SELECT users.name, COUNT(posts.user_id) AS post_count FROM users LEFT JOIN posts ON posts.user_id = users.id GROUP BY users.id 1. Yes the member's table have an id field. And where do you see forum_replies? 2. Yes, basically when an user posts, i want their post_count to increase. I knew their was a simpler way in achieving this, i just did not focus too much on sql, but i know that i have too in order to properly code programs. 3. But can you pin point the issue going around the date? Or is my queries messing everything up?
-
Ok... So the application that i am making is a forum board. To achieve this, i have 2 tables in my DB : forum_question and forum_answer. forum_question structure is: id (id of the forum_question) , username (the user's username) , topic (title) , details (the thread) , date_time (the time on which the thread was posted) , view (amount of views) , replies (amount of replies). forum_answer : question_id (the forum_question id ) , a_id (the response id) , a_username (the user's who responded username) , a_datetime (the time that the reply was posted on). AND i want the user's post_count to increase per post. So the user's DB table that im using is only the post_count. I added some comments. <?php session_start(); /* * TOO MANY QUERIES IN THIS SCRIPTS, HOWEVER WHEN I TRY TO USE JOINS AND UNIONS THE CODE DO NOT WORK * EVERYTHING WORKS BESIDES THE DATE IN THE FORUM_ANSWER PART, HOWEVER LIKE I SAID BEFORE THIS CODE IS VERY SLOPPY * WHICH MAKES SENSE OF WHY IM NOT RECEIVING THE RESULTS THAT I WANT. I BELIEVE THAT I HAVE TO RE-CODE THIS PROGRAM * IN OOP, BUT I NEED A PLACE TO KEEP MY LOGS AND THIS IS ALL I HAVE SO FAR. SO THANKS FOR HELPING */ //GET THE FILE THAT CONNECT TO THE SERVER AND SET THE DEFAULT TIME ZONE FOR THE DATE include("../includes/config.php"); ?> <html> <head> <link href="../css/main.css" type="text/css" rel="stylesheet" /> </head> <div id='header'> <h1>Home Page</h1> </div> <div id='primary_nav'> <ul> <li><a href='../index.php'>Home Page</a></li> <li><a href='index.php'>Forums</a></li> <li><a href='../index.php?app=members'>Member's Page</a></li> <li><a href='../index.php?app=members&module=account'>Account</a></li> <li><a href='../index.php?app=pages&module=extra'>Extras</a></li> </ul> </div> <div id='content'> <div id='forum_container'> <?php //GET THE VARIABLE FROM THE URL TO DISPLAY THE CORRECT THREAD $id = isset($_GET['id']) ? $_GET['id']: ''; //QUERY THE DATA THE IS IN THE FORUM_QUESTION WHERE ID = $ID IN ORDER TO GET THE TOPIC THROUGH REPLY CORRECTLY. $result = mysql_query("SELECT * FROM forum_question WHERE id='$id'"); while($row = mysql_fetch_array($result)) { //VARIABLE FOR THE USER THAT MADE THE THREAD $p_username = isset($row['username']) ? $row['username'] : ''; //GET THE USER'S POST_COUNT $post_count = mysql_query("SELECT * FROM members WHERE username='$p_username'"); //GET THE CORRECT FORMAT FOR DATE (WORKS FINE) HOWEVER, I DO NOT THINK THAT I SHOULD BE RUNNING SO MANY WHILE LOOPS WITH QUERIES. $get_date = mysql_query("SELECT DATE_FORMAT(date_time,'%a %b %d, %Y %l:%i %p') AS date_time FROM forum_question WHERE id='$id' "); while($row_1 = mysql_fetch_array($post_count)) { while($row_3 = mysql_fetch_array($get_date)) { //USERS POST_COUNT $post_count_1 = $row_1['post_count']; //VARIABLES FROM THE TABLE (FORUM_QUESTION) $topic = isset($row['topic']) ? $row['topic'] : ''; $detail = isset($row['detail']) ? $row['detail'] : ''; $view = isset($row['view']) ? $row['view'] : ''; $reply = isset($row['replies']) ? $row['replies'] : ''; //DATE IN THE CORRECT FORMAT, HOWEVER I FEEL LIKE I DO NOT NEED A SEPERATE QUERY TO ACHIEVE THIS, BUT IT WORKS. $date = isset($row_3['date_time']) ? $row_3['date_time'] : ''; //THE NEXT SECTION ON CODE, BASICALLY DISPLAY'S ALL THE VARIABLES FROM ABOVE IN A 'THREAD' FORMAT, ALL WHICH WORKS. ?> <div class='view_post'> <div class='view_post_title'> <p><?php echo $topic?></p> </div> <div class='view_post_date'> <p>Published: <?php echo $date;?></p> </div> <div class='view_post_user'> <p> Username: <?php echo $p_username;?> <br /> Post Count: <?php echo $post_count_1;?> <br /> </p> </div> <div class='view_post_content'> <p><?php echo $detail; ?></p> </div> </div> <?php }}} //END ALL THE WHILES LOOPS. //GET THE DATE FROM FORUM_ANSWER (REPLIES) $result1 = mysql_query("SELECT * FROM forum_answer WHERE question_id = '$id'"); /*CHANGE THE FORMAT OF THE DATE. MAIN ISSUE (WORKS FOR ONLY THE FIRST REPLY THEN DISPLAY THAT TIME FOR THE REST OF THE REPLIES) * HOWEVER, WHEN I JUST USE THE DATE FROM $ROW THEN IT WORKS FINE, IT JUST DO NOT DISPLAY THE FORMAT CORRECTLY */ $u_datetime = mysql_query("SELECT DATE_FORMAT(a_datetime,'%a %b %d, %Y %l:%i %p') AS a_datetime FROM forum_answer WHERE question_id='$id'"); while($row_5 = mysql_fetch_array($u_datetime)) { while($row = mysql_fetch_array($result1)) { //VARIABLES FROM FORUM_ANSWER $a_id = isset($row['a_id']) ? $row['a_id'] : ''; $a_username = isset($row['a_username']) ? $row['a_username'] : ''; $a_answer = isset($row['a_answer']) ? $row['a_answer'] : ''; $a_datetime = isset($row_5['a_datetime']) ? $row_5['a_datetime'] : ''; //GET THE USER WHO REPLIED POST_COUNT $a_post_count = mysql_query("SELECT * FROM members WHERE username='$a_username'"); while($row_2 = mysql_fetch_array($a_post_count)) { $a_post_count_1 = $row_2['post_count']; ?> <div class='view_post'> <div class='view_post_date'> <p>Published: <?php echo $a_datetime;?></p> </div> <div class='view_post_user'> <p> Username: <?php echo $a_username;?> <br /> Post Count: <?php echo $a_post_count_1; ?> <br /> </p> </div> <div class='view_post_content'> <p><?php echo $a_answer;?></p> </div> </div> <?php }}} //END ALL THE WHILES LOOPS //UPDATE THE VIEWS, GO UP PER ONE. (WORKS) $result2 = mysql_query("SELECT * FROM forum_question WHERE id='$id'"); while($row = mysql_fetch_array($result2)) { $view = isset($row['view']) ? $row['view'] : ''; //If the views is empty, give it a number value! (1) if(empty($view)) { $view = 1; $result3 = mysql_query("UPDATE forum_question SET view='$view' WHERE id='$id'"); } else{ //Count more values! $add_view = $view + 1; $result4 = mysql_query("UPDATE forum_question SET view='$add_view' WHERE id='$id'");} } ?> <br /> <div class='view_post'> <div class='view_post_title'> <p>Post Reply...</p> </div> <div class='view_post_reply'> <p> <form action='add_reply.php' method='post'> <center> <textarea name='a_answer' id='a_answer' rows='3' cols='45' style='min-height: 200px; width: 90%;'></textarea> <input name='id' type='hidden' value='<?php echo $id;?>' /><br /> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"> </center> </form> </p> </div> </div> </div> <!-- END CONTAINER TAG!--> <div id='footer'> <p>Copyright Empora Tech 2012</p> </div> </div><!-- END THE CONTENT TAG! --> </body> </html>
-
I been trying to do JOINS / UNION and im still unsuccessful.
-
I know, that is why im confused too. This is my whole file (Again, my code is sloppy, i just want this forum to work so i can start recording logs for my site.) <?php session_start(); include("../includes/config.php"); ?> <html> <head> <link href="../css/main.css" type="text/css" rel="stylesheet" /> </head> <div id='header'> <h1>Home Page</h1> </div> <div id='primary_nav'> <ul> <li><a href='../index.php'>Home Page</a></li> <li><a href='index.php'>Forums</a></li> <li><a href='../index.php?app=members'>Member's Page</a></li> <li><a href='../index.php?app=members&module=account'>Account</a></li> <li><a href='../index.php?app=pages&module=extra'>Extras</a></li> </ul> </div> <div id='content'> <div id='forum_container'> <?php $id = isset($_GET['id']) ? $_GET['id']: ''; $result = mysql_query("SELECT * FROM forum_question WHERE id='$id'"); while($row = mysql_fetch_array($result)) { $p_username = isset($row['username']) ? $row['username'] : ''; $post_count = mysql_query("SELECT * FROM members WHERE username='$p_username'"); $get_date = mysql_query("SELECT DATE_FORMAT(date_time,'%a %b %d, %Y %l:%i %p') AS date_time FROM forum_question WHERE id='$id' "); while($row_1 = mysql_fetch_array($post_count)) { while($row_3 = mysql_fetch_array($get_date)) { $post_count_1 = $row_1['post_count']; $topic = isset($row['topic']) ? $row['topic'] : ''; $detail = isset($row['detail']) ? $row['detail'] : ''; $view = isset($row['view']) ? $row['view'] : ''; $reply = isset($row['replies']) ? $row['replies'] : ''; $date = isset($row_3['date_time']) ? $row_3['date_time'] : ''; ?> <div class='view_post'> <div class='view_post_title'> <p><?php echo $topic?></p> </div> <div class='view_post_date'> <p>Published: <?php echo $date;?></p> </div> <div class='view_post_user'> <p> Username: <?php echo $p_username;?> <br /> Post Count: <?php echo $post_count_1;?> <br /> </p> </div> <div class='view_post_content'> <p><?php echo $detail; ?></p> </div> </div> <?php }}} $result1 = mysql_query("SELECT * FROM forum_answer WHERE question_id = '$id'"); $u_datetime = mysql_query("SELECT DATE_FORMAT(a_datetime,'%a %b %d, %Y %l:%i %p') AS a_datetime FROM forum_answer WHERE question_id='$id'"); while($row_5 = mysql_fetch_assoc($u_datetime)) { while($row = mysql_fetch_array($result1)) { $a_id = isset($row['a_id']) ? $row['a_id'] : ''; $a_username = isset($row['a_username']) ? $row['a_username'] : ''; $a_answer = isset($row['a_answer']) ? $row['a_answer'] : ''; $a_datetime = isset($row['a_datetime']) ? $row['a_datetime'] : ''; $a_post_count = mysql_query("SELECT * FROM members WHERE username='$a_username'"); while($row_2 = mysql_fetch_array($a_post_count)) { $a_post_count_1 = $row_2['post_count']; echo "<pre>"; print_r($row); echo "</pre><br />"; ?> <div class='view_post'> <div class='view_post_date'> <p>Published: <?php echo $a_datetime;?></p> </div> <div class='view_post_user'> <p> Username: <?php echo $a_username;?> <br /> Post Count: <?php echo $a_post_count_1; ?> <br /> </p> </div> <div class='view_post_content'> <p><?php echo $a_answer;?></p> </div> </div> <?php }}} $result2 = mysql_query("SELECT * FROM forum_question WHERE id='$id'"); while($row = mysql_fetch_array($result2)) { $view = isset($row['view']) ? $row['view'] : ''; //If the views is empty, give it a number value! (1) if(empty($view)) { $view = 1; $result3 = mysql_query("UPDATE forum_question SET view='$view' WHERE id='$id'"); } else{ //Count more values! $add_view = $view + 1; $result4 = mysql_query("UPDATE forum_question SET view='$add_view' WHERE id='$id'");} } ?> <br /> <div class='view_post'> <div class='view_post_title'> <p>Post Reply...</p> </div> <div class='view_post_reply'> <p> <form action='add_reply.php' method='post'> <center> <textarea name='a_answer' id='a_answer' rows='3' cols='45' style='min-height: 200px; width: 90%;'></textarea> <input name='id' type='hidden' value='<?php echo $id;?>' /><br /> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"> </center> </form> </p> </div> </div> </div> <!-- END CONTAINER TAG!--> <div id='footer'> <p>Copyright Empora Tech 2012</p> </div> </div><!-- END THE CONTENT TAG! --> </body> </html>
-
Array ( [a_datetime] => 2012-08-11 01:07:29 ) Array ( [a_datetime] => 2012-08-11 10:57:27 )
-
Array ( [a_datetime] => Sat Aug 11, 2012 1:07 AM ) Array ( [a_datetime] => Sat Aug 11, 2012 1:07 AM )
-
Yes. Again it the code works without my trying to change the format.
-
The format works fine. The issue is that its doing this: DB TIMES. First Reply Time = Sat Aug 11, 2012 12:45 AM; Second Reply Time = Sat Aug 11, 2012 12:50 AM However instead its doing: First Reply Time = Sat Aug 11, 2012 12:45 AM; Second Reply Time = Sat Aug 11, 2012 12:45 AM; Third Reply Time = Sat Aug 11, 2012 12:45 AM; So its using the first time for all. However it only does this when i try the date_format query or date function. //CODE IS EXTREMELY MESSY AND UNORGANIZED $result1 = mysql_query("SELECT * FROM forum_answer WHERE question_id = '$id'"); $u_datetime = mysql_query("SELECT DATE_FORMAT(a_datetime,'%a %b %d, %Y %l:%i %p') AS a_datetime FROM forum_answer WHERE question_id='$id'"); while($row_5 = mysql_fetch_assoc($u_datetime)) { while($row = mysql_fetch_array($result1)) { $a_id = isset($row['a_id']) ? $row['a_id'] : ''; $a_username = isset($row['a_username']) ? $row['a_username'] : ''; $a_answer = isset($row['a_answer']) ? $row['a_answer'] : ''; $a_datetime = isset($row_5['a_datetime']) ? $row_5['a_datetime'] : ''; $a_post_count = mysql_query("SELECT * FROM members WHERE username='$a_username'"); while($row_2 = mysql_fetch_array($a_post_count)) { $a_post_count_1 = $row_2['post_count']; ?> <div class='view_post'> <div class='view_post_date'> <p>Published: <?php echo $a_datetime;?></p> </div> <div class='view_post_user'> <p> Username: <?php echo $a_username;?> <br /> Post Count: <?php echo $a_post_count_1; ?> <br /> </p> </div> <div class='view_post_content'> <p><?php echo $a_answer;?></p> </div> </div>
-
Still no luck I tried using a the query date format, but then the date don't even show up.
-
Sorry for bothering you guys soo much about the time thing but this is the update on the issue: The time is going into the DB on the correct time due to the now() function and i found out how to change the format of the time. However it is not dispaly the correct time on the site. Example: The DB time / date is : 2012-08-11 01:06:06 However on the site is saying: Sat Aug 11, 2012 1:01 am. I tried all of these.. $date = isset($row['date_time']) ? $row['date_time'] : ''; $date = strtotime($date); $date = date("D M d, Y g:h a", $date); $date = isset($row['date_time']) ? $row['date_time'] : ''; $date = date("D M d, Y g:h a", strtotime($date)); and received no luck. However when i did.. $date = isset($row['date_time']) ? $row['date_time'] : ''; Without trying to change the format, its works fine.
-
Ok i get what you are saying. Now for the issue involving the You can simply UPDATE table SET field = field + 1 WHERE I tried this, and now my code doesn't work. Example, for post count i would just do UPDATE members SET post_count = post_count + 1 WHERE username='$username' However that doesnt work, i also tried UPDATE members SET post_count = 'post_count + 1' WHERE username='$username' and it doesnt work either.
-
What do you mean by i dont really need to store the data that can be derived from the table itself?
-
Ok, so can i use a format inside the now() function? Or would have to convert the format from my DB to the format i want that is on my site? EX. The format is 2012-08-10 23:29:09 but i want it to this format AUG 11, 2012 11:30 pm.
-
Ok.. I'm storing the date in my DB because i want to know when a user is registered and when a user posts and replies. What SHOULD happen : User is registered on AUG 11, 2012 11:30 pm. So the DB should record AUG 11, 2012 11:30 pm. However this is happening: User is registered on AUG 11, 2012 11:30 pm. So the DB is recording AUG 10, 2012 10:10 pm (Which is happening to ALL my inputs. SO regardless of the time, its recording that date / time). Example Code <?php session_start(); //ADD TOPIC! include("../includes/config.php"); if(isset($_POST['submit'])) { $username = isset($_SESSION['username']) ? $_SESSION['username']: ''; $topic = $_POST['topic']; $detail = $_POST['detail']; $date = date("D M d, Y g:h a" , time()); $result_user = mysql_query("SELECT * FROM members WHERE username='$username'"); while($row = mysql_fetch_array($result_user)) { if(empty($row['post_count'])) { $post_count = 1; } else { $post_count = $row['post_count'] + 1; //ADDING ONE PER POST! } $post_add = mysql_query("UPDATE members SET post_count='$post_count' WHERE username='$username'") or die(mysql_error()); $result = mysql_query("INSERT INTO forum_question(id,username,topic,detail,date_time) VALUES('','$username','$topic','$detail','$date')"); if($result_user && $post_add) { echo "SUCCESS!"; echo "<br /><a href='index.php'>View Topics.</a>"; } else if(!$post_add) echo "result user error!"; else echo "Result error!"; } } ?>
-
im having a date issue... In my code, when something is being added to my DB, i use the function... date("D M d, Y g:h a" , time()); But what ends up happening is that in the DB, it is only keeping one default time... So instead of the current date, its adding 8/10/2012 10:10 pm...
-
Hello, Im making a forum board and in my view_topics.php page, the layout is the basic.... In one big DIV is : title, published date, then its a float left (user content), then a float right (actual content). While I want the user content height to match with the actual content height. Example: The user content have a background, and i want it to match the actual content. So if the actual content height is 600px; then i want the user's content height to be 600px;. I assume that a min-height would work, if i gave both user content and actual content the same height index, but it doesn't and im stuck.
-
The error that i was overwriting the variable $post_count.. so i just changed the name. Thanks tho
-
What do mean? Are you asking what code do you need in order for your script to work? So when the user clicks submit, it goes to the registration file which would register the user into a database?
-
OK, so im working on a mini forum board, and i ran into some problems... On my view_topic.php file i want the user to be able to see his post_count... which is simple because all i have to do is do a mysql_query and a mysql_fetch_array. , which works fine. However i am getting a warning... "Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\wamp\www\EmporaTech_Site\forum\view_topic.php on line 40".. <?php $id = isset($_GET['id']) ? $_GET['id']: ''; $result = mysql_query("SELECT * FROM forum_question WHERE id='$id'"); while($row = mysql_fetch_array($result)) { $username = isset($row['username']) ? $row['username'] : ''; $post_count = mysql_query("SELECT * FROM members WHERE username='$username'"); while($row_1 = mysql_fetch_array($post_count)) { $post_count = $row_1['post_count']; $topic = isset($row['topic']) ? $row['topic'] : ''; $detail = isset($row['detail']) ? $row['detail'] : ''; $view = isset($row['view']) ? $row['view'] : ''; $reply = isset($row['replies']) ? $row['replies'] : ''; $date = isset($row['date_time']) ? $row['date_time'] : ''; ?> PS... I have a curly brace for the while statement further down in my script, so that's not the issue.
-
Ok thanks. Now, the code is working (finally)
-
Ok, I get a blank page, when their is no module, and i get a 1 for when module equal something. index.php?app=member : blank; index.php?app=member&module=something = 1;