Jump to content

liam1412

Members
  • Posts

    170
  • Joined

  • Last visited

    Never

Everything posted by liam1412

  1. Vbullettin is a good one. Think it cost about 80 quid tho. The search results it brings back in google are amazin. Type my sheffield forum user name in speech marks in to google "liam1412". It picks up nearly every post I have ever made on there
  2. When I first open the topic the page number is not set. If that is the only page then the pagination should not show any links but if there is only one post it is showing teh option to go back and it shouldn't. If i press back that's when it goes to minus 1
  3. Hi basically as above. if there is only one post in the topic selected it offers the option to go back and when clicking it it obviously goes to pageno=-1 which displays nothing but mysql_errors. Can anyone see why <?php //Decide if to display the topic if pageno is not set or set to 1 if(!isset($_GET['pageno']) || ($_GET['pageno'] == 1)){ ?> //display the topic - collected above this but irrelevant to query <table class="topic" cellspacing="1"> <tr> <td class="comment_date" colspan="3"> <?php echo $topic_start_datetime; ?> </td> </tr> <tr> <td class="comment_poster" valign="top"> <a href="view_profile.php?userid=<?php echo $topic_starter_id ; ?>"><?php echo $username;?></a> <br /> <img src="images/profilepics/<?php echo $user_ava; ?>" alt="avatar" border="2"> <br /> <b>Member Since:</b><br /> <?php echo $member_since; ?> <br /> <b>Location:</b><br /> <?php echo $location; ?> </td> <td class="comment_text" valign="top" colspan="2"> <?php echo $text; ?> </td> </tr> </table> //And then I collect the replies from the seperate table <?php }//clsoe the if statement that dictates with to display the topic or not. $limit = 5; if(isset($_GET['pageno'])){ $page_no = $_GET['pageno']; } else { $page_no = 1; } $select = "SELECT * FROM forum_answer WHERE ans_topic_id = $topic_id"; $query = mysql_query($select); $no_rows = mysql_num_rows($query); $rows_per_page = 5; $last_page = ceil($no_rows/$rows_per_page); if($page_no < 1){ $page_no = 1; } elseif ($page_no > $last_page){ $page_no = $last_page; } $page = ($page_no - 1) * $rows_per_page; if($no_rows != 0){ $select = "SELECT * FROM forum_answer WHERE ans_topic_id = $topic_id ORDER BY ans_datetime ASC LIMIT $page,$rows_per_page"; $query = mysql_query($select); while($get_replies = mysql_fetch_array($query)){ $date = $get_replies['ans_datetime']; $poster_id = $get_replies['ans_poster_id']; $text = $get_replies['ans_text']; $text = nl2br($text); $text = BBCODE($text); $poster = "SELECT * FROM users WHERE userid = '$poster_id'"; $poster_query = mysql_query($poster); $poster_array = mysql_fetch_array($poster_query); $username = $poster_array['username']; $member_since = $poster_array['signup_date']; $avatar = $poster_array['avatar']; $location = $poster_array['location']; ?> <table class="forum_reply" cellspacing="1"> <tr> <td class="reply_date" colspan="2"><?php echo $date; ?></td> </tr> <tr> <td class="reply_poster"> <a href="view_profile.php?userid=<?php echo $poster_id ; ?>"><?php echo $username;?></a> <br /> <img src="images/profilepics/<?php echo $avatar; ?>" alt="avatar" border="2"> <br /> <b>Member Since:</b><br /> <?php echo $member_since; ?> <br /> <b>Location:</b><br /> <?php echo $location; ?> </td> <td class="reply" valign="top"><?php echo $text; ?></td> </tr> </table> <?php } } ?> <div class="pagination"> <? if ($page_no == 1) { echo "FIRST PREV"; } else { echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=1'>FIRST</a> "; $prevpage = ($page_no-1); echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$prevpage'>PREV</a> "; } echo " -- $page_no of $last_page -- "; if ($page_no == $last_page) { echo " NEXT LAST "; } else { $nextpage = ($page_no+1); echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$last_page'>LAST</a> "; } ?>
  4. Hi I have my forum in 2 tables forum_question forum_answer I collect the question and display that, then collect all the replies using a while loop. I have a pagination script for the view_topic part of my forum. I have included an if statement so that if the pageno is not set in the URL then it wil display the question and if it is it won't. the problem is this The first time I open the topic it displays the question then all the answers but then if i browse the the other pages then press back in my pagination then the pageno is the set in the URL so it doesn't dispaly the question. How can I get round this. Does this even make any sense??? Basically if my result set returns 30 rows then it will be on 3 pages. But the question which is the first post only wants to to be on the first page of 3!!!! Any way here is my script!!! <?php //the if statement if(!isset($_GET['pageno'])){ ?> <table class="topic" cellspacing="1"> <tr> <td class="comment_date" colspan="3"> <?php echo $topic_start_datetime; ?> - <?php echo $topic; ?> </td> </tr> <tr> <td class="comment_poster" valign="top"> <a href="view_profile.php?userid=<?php echo $topic_starter_id ; ?>"><?php echo $username;?></a> <br /> <img src="images/profilepics/<?php echo $user_ava; ?>" alt="avatar" border="2"> <br /> <b>Member Since:</b><br /> <?php echo $member_since; ?> <br /> <b>Location:</b><br /> <?php echo $location; ?> </td> <td class="comment_text" valign="top" colspan="2"> <?php echo $text; ?> </td> </tr> </table> <?php } $limit = 5; if(isset($_GET['pageno'])){ $page_no = $_GET['pageno']; } else { $page_no = 1; } $select = "SELECT * FROM forum_answer WHERE ans_topic_id = $topic_id"; $query = mysql_query($select); $no_rows = mysql_num_rows($query); $rows_per_page = 5; $last_page = ceil($no_rows/$rows_per_page); if($page_no < 1){ $page_no = 1; } elseif ($page_no > $last_page){ $page_no = $last_page; } $page = ($page_no - 1) * $rows_per_page; $select = "SELECT * FROM forum_answer WHERE ans_topic_id = $topic_id ORDER BY ans_datetime ASC LIMIT $page,$rows_per_page"; $query = mysql_query($select); ?> <?php while($get_replies = mysql_fetch_array($query)){ $date = $get_replies['ans_datetime']; $poster_id = $get_replies['ans_poster_id']; $text = $get_replies['ans_text']; $text = nl2br($text); $text = BBCODE($text); $poster = "SELECT * FROM users WHERE userid = '$poster_id'"; $poster_query = mysql_query($poster); $poster_array = mysql_fetch_array($poster_query); $username = $poster_array['username']; $member_since = $poster_array['signup_date']; $avatar = $poster_array['avatar']; $location = $poster_array['location']; ?> <table class="forum_reply" cellspacing="1"> <tr> <td class="reply_date" colspan="2"><?php echo $date; ?></td> </tr> <tr> <td class="reply_poster"> <a href="view_profile.php?userid=<?php echo $poster_id ; ?>"><?php echo $username;?></a> <br /> <img src="images/profilepics/<?php echo $avatar; ?>" alt="avatar" border="2"> <br /> <b>Member Since:</b><br /> <?php echo $member_since; ?> <br /> <b>Location:</b><br /> <?php echo $location; ?> </td> <td class="reply" valign="top"><?php echo $text; ?></td> </tr> </table> <?php } ?> <div class="post_reply"> <a href="post_reply.php?topic_id=<?php echo $topic_id;?>&forum_id=<?php echo $forum_id;?>">Post reply</a> </div> <div class="pagination_right"> <? if ($page_no == 1) { echo "FIRST PREV"; } else { echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=1'>FIRST</a> "; $prevpage = ($page_no-1); echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$prevpage'>PREV</a> "; } echo " -- $page_no of $last_page -- "; if ($page_no == $last_page) { echo " NEXT LAST "; } else { $nextpage = ($page_no+1); echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?topic_id=$topic_id&pageno=$last_page'>LAST</a> "; } ?> </div> </div> <?php if($no_of_views == 99){ $sql_hot_topic = "UPDATE forum_question SET topic_status = $topic_update WHERE topic_id = '$topic_id'"; mysql_query($sql_hot_topic)or die("unable to update topic status"); } $sql_update_topic_view = "UPDATE forum_question SET topic_view = '$topic_view' WHERE topic_id = '$topic_id'"; mysql_query($sql_update_topic_view)or die("failed to update topic_reply"); mysql_close(); ?> <?php include 'footer.php'; ?>
  5. Anyone know where I can find out how to do this or give me a rough idea that I can work with
  6. GEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEENIOUS!!!!! I ******** hate it when it is summat that small. Sometimes just takes a 2nd pair of eyes. Thanks Mate
  7. Hey up People Well I have this little script that took me ages. Basically it's an image upload but I want people to be able to Select the picture they are uploading as there default so It will appear on there profile. Its been working for the last few days, but just gone on to show my mate today and no matter if the box is checked or not its setting the default flag ??? Any way here is my code <input class="input" type="checkbox" name="default" value="default" /> And the PHP it posts to. I must have just deleted summat by mistake but can't I chuffin spot it <?php session_start(); $username = $_SESSION['username']; $userid = $_GET['userid']; $img_cap = $_POST['caption']; $default = '0'; $host = 'localhost'; $db_username = 'root'; $db_password = ''; $db_name = 'klubdeutsch'; mysql_connect("$host" , "$db_username" , "$db_password")or die("Cannot Connect to Server"); mysql_select_db("$db_name")or die("Cannot connect to Database"); if(isset($_POST['default'])){ if($_POST['default'] == 'default'){ $default = '1'; } } if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)){ $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["size"] < 350000)){ $newname = dirname(__FILE__).'/images/profilepics/'.$username.$filename; if (!file_exists($newname)){ if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))){ if($default = '1'){ $def_img_query = "SELECT * FROM images WHERE user_id='$userid' AND def_img='1'"; $query = mysql_query($def_img_query); $num_rows = mysql_num_rows($query); if($num_rows != 0){ $array = mysql_fetch_array($query); $img_id = $array['img_id']; $remove_def_flag = mysql_query("UPDATE images SET def_img = 0 WHERE img_id='$img_id'"); } } $sql_update_images = mysql_query("INSERT INTO images (user_id, img_src, img_cap, def_img) VALUES ('$userid', '$username$filename', '$img_cap', '$default')")or die(mysql_error()); { header("location:profile_test.php?userid=$userid"); } } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> Anyways hope you all have a good evening and happy hunting. I been looking at it for over an hour!!!!!!
  8. Sorry.  I did write my problem but cut it to move it. must not have pasted it in.  But your right that was what is worng. without even knowing. ha ha Cheers Ninja
  9. Thsi si the code for my checkbox [code]<input class="input" type="checkbox" name="default" value="default" />[/code] and here is my bit of code which should change the variable default from 0 to 1 if the box is ticked. [code]if(isset($_POST['default'])){ if($default == 'default'){ $default = '1'; } }[/code]
  10. I have a form that users can add a car to the list on there profile.  if there is more then 5 it deletes the last one and replaces it with the new one.  I want that one to remain on top but its ending up wherever it feels like. The first bit of code is the display of the list. the second bit adds to the list and deletws if neccessary. 
  11. I also have a query that deletes the oldest one if there are more than 5.  Just in case you need it [code]<?php session_start(); $userid = $_GET['userid']; $plate = $_POST['plate']; $make = $_POST['make']; $model = $_POST['model']; $engine = $_POST['engine']; $host = 'localhost'; $db_username = 'root'; $db_password = ''; $db_name = 'klubdeutsch'; mysql_connect("$host" , "$db_username" , "$db_password")or die("Cannot Connect to Server"); mysql_select_db("$db_name")or die("Cannot connect to Databse"); $last5 = "SELECT * FROM last_cars WHERE userid='$userid'"; $last5_query = mysql_query($last5); $total = mysql_num_rows($last5_query); if($total == 5){ $oldest_car = "SELECT * FROM last_cars WHERE userid='$userid' ORDER BY car_id ASC LIMIT 1"; $query = mysql_query($oldest_car); $result = mysql_fetch_array($query); $car_id = $result['car_id']; $delete_oldest = "DELETE FROM last_cars WHERE car_id='$car_id'"; $query = mysql_query($delete_oldest)or die('Dint Work'); } $add_new = ("INSERT INTO last_cars (userid, plate, make, model, engine) values('$userid' , '$plate' , '$make' , '$model' , '$engine')")or die('Dint Work 2'); $add_car = mysql_query($add_new); if($add_car){ header("location:profile2.php?userid=$userid"); }else{ echo broke; } ?>[/code]
  12. Figured it. Sorry to bother you.  For some strange reason im using one query in the head for selecting and this one further down for counting.  Why I do not know.
  13. Will this bit do.  Its my first scropt so go easy. lol [code]<?php  $last_cars = "SELECT * FROM last_cars WHERE userid='$userid' ORDER BY car_id ASC"; $last_query = mysql_query($last_cars); $no_cars = mysql_num_rows($last_query); ?> <div class="last5"> <table width="396" cellpadding="6" cellspacing="1"> <tr> <td class="header2" colspan="4" bgcolor="#565656">Previous Cars - <?php if($username == $_SESSION['username']){echo ?><a href="edit_last5.php?userid=<?php echo $userid?>">Change</a><?php } ?></td> </tr> <tr> <td class="grey" colspan="4" width="400" bgcolor="#6d6d6d">Love em or hate. Your last 5 cars. BE HONEST!!!</td> </tr> <tr> <td class="header3" width="50" bgcolor="#6d6d6d">Year</td> <td class="header3" width="150" bgcolor="#6d6d6d">Make</td> <td class="header3" width="150" bgcolor="#6d6d6d">Model</td> <td class="header3" width="45" bgcolor="#6d6d6d">Engine</td> </tr> <?php while($car_result = mysql_fetch_array($last_query)){ $plate = $car_result['plate']; $make = $car_result['make']; $model = $car_result['model']; $engine = $car_result['engine']; ?> <tr> <td class="grey" width="50" bgcolor="#6d6d6d"><?php echo $plate; ?></td> <td class="grey" width="150" bgcolor="#6d6d6d"><?php echo $make; ?></td> <td class="grey" width="150" bgcolor="#6d6d6d"><?php echo $model; ?></td> <td class="grey" width="45" bgcolor="#6d6d6d"><?php echo $engine; ?></td> </tr> <?php } ?> </table>[/code]
  14. It is a very long script for quite a detailed profile page. you want it all
  15. [code]$last_cars = "SELECT * FROM last_cars WHERE userid='$userid' ORDER BY car_id ASC"; [/code] Just echoing em out random when im using a while loop to go through the result set.
  16. Thanks so much mate.  Thats all I needed to Know.  Now I know collect the date time from that result and execute my delete. phew. Got there in the end. thanks everyone for all you help.
  17. Querying my database isn't the issue.  What i don't understand is where I get the value to compare it with.  Lets just pretend im not adding a time field and using the primary key. my code $last5 = "SELECT * FROM last_5 WHERE userid=$userid ORDER BY car_id ASC"; $query = mysql_query($last_5); Will return upto 5 records. if it does return 5 I want to delete the first one to make way for the new one.  Where do I go from here. 
  18. Im okay with adding a time column what I need to know is how to select the oldest record from the database.  Do I need to fetch them all back ro is there a way of just selecting it form the database. if I do need to fetch them all back what is the code for the picking the oldest.
  19. But the then time is just a string. I thought string was just text regardless of wether it has numbers in it so how do you then compare which is the oldest.  I think it might be time for bed and hit this with a clear head in the morning. lol  ;D
  20. Sp im right in saying that when you don't use a while loop then mysql only fetch's back the oldest record  in the record set. i have only ever collected the one row need or echoed out all the rows by using a while loop.  Basically if I don't use a while loop does it bring abck the whole lot in one massive array!!!
  21. [quote]In order to delete the oldest record reliably you need a date field. An autoincrement field is NOT to be relied upon for such tasks, that is NOT at all what it is designed for.[/quote] SO supposing a did add a date field which im assuming (using now() or date() ?? ?? Which one ???) then I would obviously order by date Ascending. So then if i just use mysql_fetch_array this record taht it fetches back should be the oldest. i can then collect the car id from that and execute the delete.  Maybe I have misunderstood or im just ssuming coz now I think about it I haven't seen taht mentiond.  Man Im lost  ;D  ??? ??? ???
×
×
  • 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.