Jump to content

final60

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

final60's Achievements

Member

Member (2/5)

0

Reputation

  1. I am modifying some javascript for Google maps so that the different pin information is retrieved from my database. If I was to do this with just php it would be like this: <?php while($row = mysql_fetch_assoc($query)) {$title = $row['title']; $desc = $row['desc']; echo 'This '.$title .' and this '. $desc .';}?> If there were 5 rows in the database there will be five lines with 5 different titles and descriptions. But I have this line of javascript that I would like to be in a while loop: map.addMarkerByLatLng(37.8685, -1.5108, "Sanatario de Terburculosos", createInfo("title goes here","")); How can i write it so that that javascript is in a php while loop or how can i do the javascript equivelant of the php while loop so that i can retrieve multiple rows of lang,lat info each in its own javascript code like above? Thank you.
  2. for some reason when i empty the tables and start creating new posts it displays them properly until I create say the 8th or 9th post in that category and then it shows the duplicate error. but im not sure how it would duplicate if the post_id's are all unique whihch keeps each row unique in the is_read table which consists of post_id, user_id ,is_read (0/1).
  3. Hi Im receiving this error using the following mysql statement: SELECT posts.title, posts.content, posts.date, (SELECT user.username FROM urbex_users AS user WHERE user.user_id = posts.user_id) AS username, (SELECT count(reply_id) FROM urbex_forum_replies AS rep WHERE rep.post_id = posts.post_id)AS replies, cat.category_name, posts.sticky, posts.post_id, is_read.post_id, (SELECT is_read.is_read FROM urbex_forum_posts_is_read AS is_read WHERE posts.post_id = is_read.post_id AND is_read.user_id = 14) AS is_read, posts.user_id FROM urbex_forum_posts AS posts, urbex_forum_categories AS cat, urbex_forum_posts_is_read AS is_read, urbex_users AS users WHERE posts.category_id = cat.category_id AND posts.post_id = is_read.post_id AND posts.user_id = is_read.user_id AND users.user_id = posts.user_id AND posts.sticky = 0 AND cat.category_id = 1 ORDER BY posts.date DESC I checked the tables and as far as I can see there are no duplications anywhere. post_id is the pk for posts table which would make everything all posts unique in both the posts table and the is_read one? When a new post is created a new entry is made in both the posts table and the is_read table. The query works fine when I remove the is_read sub query. But I need it to tell the user when a new post or reply has been made.
  4. DOH found i. Always the little things I miss grrrr. I forgot to repeat the catid and catname in the ternary operator..
  5. Hi Im using basic pagination to split up forum threads. For some reason when a page link is clicked the GET info is not passed in the url and the page number is: $per_page = 5; $page_query = mysql_query("SELECT count(post_id) FROM urbex_forum_posts"); $pages = ceil(mysql_result($page_query, 0) / $per_page); $page = (isset($_GET )) ? (int)$_GET['page']: 1; $start = ($page - 1) * $per_page; if($pages >=1 && $page <=$pages) { for($x=1;$x<=$pages;$x++) { echo $_GET['cat_id'].' '.$_GET['cat_name']; $cat_id = $_GET['cat_id']; $cat_name = $_GET['cat_name']; echo ($x == $page) ? '<a href="?cat_id='.$cat_id.'&cat_name='.$cat_name.'&page='.$x.'">['.$x.']</a>' : '<a href="?page='.$x.'">'.$x.'</a>'; } } $query2 = mysql_query("query...."); ... thanks for any help.
  6. It is just the single form. the cat_id is passed to the page in the url which i was trying to input directly using GET in the mysql_query which wouldnt work, I also tried putting the cat_id in a variable first but nada. Ive changed it to using a hidden input field with the cat_id echoed into its value which works fine, but would have rather not done that.
  7. yeah its frustrating. I just used a hidden input type with the cat_id echo into it and it submits the data fine that way, but that doesnt solve the issue really :/ I Appreciate your efforts..
  8. No, sorry I shoul dhave been clearer (edited previous post too late) it echos 1, but when i try to insert that in the database it always enters 0
  9. it is set as int(11) when echo'd on the page it displays 1.
  10. Hi, Im having a problem with inserting my forum category id into the datase when a new forum post is submitted. Heres part of the markup $cat_id = $_GET['cat_id']; if(isset($submit) && ($title != 'Title') && strlen($title)>5) { if(!empty($title) ) { if(!empty($content) && ($content != 'Enter your post content here..') && strlen($content)>9) { mysql_query("INSERT INTO urbex_forum_posts (user_id,title,content,date,sticky,category_id) VALUES('$_SESSION[urbex_user_id]','$title','$content',NOW(),'0','$_GET[cat_id]')"); }else{ echo "<p>Could not process post: Please make sure the content is atleast 10 characters!</p>"; } }else{ echo "<p>Could not process post: Please make sure the title is atleast 6 characters!</p>"; } } When I use both $cat_id or just $_GET['cat_id'] both submit 0 into the cell in the database table. When I echo both out on the page the both echo the correct category name.
  11. thanks that helped alot would the foreach have worked just out of interest?
  12. is this in the right direction? Ive not yet started using foreach loops but it seems the right kind of thing. SO when a new post or reply is created something similar to this code is used $users = mysql_query("SELECT user_id FROM urbex_users"); foreach($users as $each_user) { mysql_query("INSERT INTO urbex_forum_posts_is_read AS is_read (post_id,user_id,is_read)VALUES("$_GET[post_id]","$each_user","0")"); } and when the user views the post it sets is_read back to 1 mysql_query("UPDATE urbex_forum_posts_is_read SET is_read='0' WHERE post_id='$_GET[post_id]' AND user_id='$_SESSION[urbex_user_id]'"); not sure if im barking up the right tree tbh
  13. Hi Im currently coding a simple php/mysql forum and am stuck on how to alert the user when a someone has replied to a post on the fourm. Currently I have the following tables: forum_posts post_id pk user_id title content date is_sticky cat_id forum_replies reply_id pk user_id reply_date reply_content post_id post_is_read post_id user_id is_read (0/1) SO far Ive thought that the best way to do it is when a new post is created a row is made in post_is_read for all users with is_read set to 0. Then a text can be displayed saying "new post". Then when the user views the post the row that is equal to their username, the post_id has the is_Read set to 1. Then when a new reply is made on the post it sets is_Read back to 0 for all users again. But How do I first retrieve each user_id from users table and insert a new row in is_read table with post_id, user_id, is_read=0 for each user? Is there a better way to do the whole thing ? thanks for any help
  14. Thanks. dammit what an idiot! and yup ill do encryption etc as next step!
×
×
  • 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.