Jump to content

astralaaron

Members
  • Posts

    1,254
  • Joined

  • Last visited

Everything posted by astralaaron

  1. Hey the nextbutton works now the link just needed to be mmabjj_viewtopic instead of just viewtopic.and on page 2 the previous button works too. the 'last' button sends me to a weird page though:http://localhost/vikingbjj/mmabjj_viewtopi...e=1.06666666667
  2. Here I will post the whole code so far, maybe you can spot the problem <?php// Start sessionsession_start();// Check if the user already is logged in if ((!isset( $_SESSION['loggedin'] )) || (!$_SESSION['loggedin'])) { header( 'Location: login.php' ); exit();}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE>MMA and BJJ message forum</TITLE> <META name="abstract" content=""> <META name="description" content=""> <META name="keywords" content=""> <META name="Revisit-After" content="10"> <META HTTP-EQUIV="Content-Language" content="EN"> <META name="distribution" content="global"> <link rel="stylesheet" type="text/css" href="forum.css"> <link rel="stylesheet" type="text/css" href="input.css"> </HEAD><BODY><div id="top"><?php if ((!isset( $_SESSION['loggedin'] )) || (!$_SESSION['loggedin'])) { echo "<p class=\"log\">Welcome Guest <a href=\"login.php\">Log In</a>"; } else { echo ("<p class=\"log\">Welcome ". ($_SESSION['user']) . " <a href=\"logout.php\">log out</a></p>"); } ?></div><div id="sitemap"><p><a class="menu" href="index.php" title="VikingBJJ home page">VikingBJJ.com</a> >>> <a class="menu" href="mmabjj.php" title="Back to MMA & BJJ forum">MMA & BJJ Forum</a></p></div><div id="forumbody"><?php$host="localhost"; // Host name $username="root"; // Mysql username $password="********"; // Mysql password $db_name="vikingbjj"; // Database name $tbl_name="mmabjj_question"; // Table name // Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");// get value of id that sent from address bar $id=intval($_GET[id]);$page = intval($_GET );if ($page < 1) $page = 1;$per_page = 15;$start = (($page - 1) * $per_page);$sql="SELECT * FROM $tbl_name WHERE id=$id";$result=mysql_query($sql);$rows=mysql_fetch_array($result);?><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFF00"><tr><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" "bgcolor="#000055"><tr><td bgcolor="#000055"><p><?php echo $rows['topic']; ?></p></td></tr><tr><td bgcolor="#000055"><p><?php echo wordwrap($rows['detail'], 26, "\n", true); ?></p></td></tr><tr><td bgcolor="#000055"><p>By : <?php echo $rows['name']; ?> Email : <?php echo $rows['email'];?></p></td></tr><tr><td bgcolor="#000055"><p>Date/time : <?php echo $rows['datetime']; ?></td></tr></table></td></tr></table><BR><?php$tbl_name2="mmabjj_answer"; // Switch to table "forum_answer" $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id' LIMIT {$start}, {$per_page}";$result2=mysql_query($sql2);while($rows=mysql_fetch_array($result2)){?><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFF00"><tr><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFF00"><tr><td bgcolor="#000055" align="right"><p>ID:</p></td><td bgcolor="#000055"><p><?php echo $rows['a_id']; ?></p></td></tr><tr><td width="10%" bgcolor="#000055" align="right"><p>Name:</p></td><td width="90%" bgcolor="#000055"><p><?php echo $rows['a_name']; ?></p></td></tr><tr><td width="10%" bgcolor="#000055" align="right"><p>Email:</p></td><td bgcolor="#000055"><p><?php echo $rows['a_email']; ?></p></td></tr><tr><td width="10%" bgcolor="#000055" align="right"><p>Reply:</p></td><td width="90%" bgcolor="#000055" width="50%"><p><?php echo $rows['a_answer']; ?></p></td></tr><tr><td width="10%" bgcolor="#000055" align="right"><p>Date/Time:</p></td><td width="90%" bgcolor="#000055"><p><?php echo $rows['a_datetime']; ?></p></td></tr></table></td></tr></table><br><?php}$cnt_res = mysql_query( "SELECT COUNT(*) FROM $tbl_name2 WHERE question_id=$id" ); $total_count = intval(mysql_result( $cnt_res, 0 ));$total_pages = $total_count / $per_page;if ($total_pages > 1) { $tags = array(); if ($page == 1) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=1">', '</a>' ); // First $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page - 1) . '">', '</a>' ); // Previous } echo $tags[0][0] . '<< First' . $tags[0][1] . ' '; echo $tags[1][0] . '< Previous' . $tags[1][1] . ' ';}for ($i=1; $i <= $total_pages; $i++) { if ($i == $page) echo '<span class="disabled_page">'; // changed the class else echo '<a href="viewtopic.php?id=' . $id . '&page=' . $i .'">'; echo $i; if ($i == $page) echo '</span>'; else echo '</a>'; echo ' ';}if ($total_pages > 1) { $tags = array(); if ($page >= $total_pages) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . $total_pages . '">', '</a>' ); // Last $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page + 1) . '">', '</a>' ); // Next } echo $tags[1][0] . 'Next >' . $tags[1][1] . ' '; echo $tags[0][0] . 'Last >>' . $tags[0][1] . ' ';} $sql3="SELECT view FROM $tbl_name WHERE id=$id";$result3=mysql_query($sql3);$rows=mysql_fetch_array($result3);$view=$rows['view'];// if have no counter value set counter = 1if(empty($view)){$view=1;$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id=$id";$result4=mysql_query($sql4);}// count more value$addview=$view+1;$sql5="update $tbl_name set view='$addview' WHERE id=$id";$result5=mysql_query($sql5);mysql_close();?><table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFF00"><tr><form name="form1" method="post" action="mmabjj_answer.php"><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#000055"><tr><td width="18%" bgcolor="#000055"><p>Name:</td><td width="3%" bgcolor="#000055"> </td><td width="79%" bgcolor="#000055"><p><?php echo ($_SESSION['user']); ?><input name="a_name" type="text" id="a_name" size="45" value="<?php echo ($_SESSION['user']); ?>" style="visibility=hidden;" /></td></tr><tr><td bgcolor="#000055"><p>Email:</td><td bgcolor="#000055"> </td><td><p><?php echo ($_SESSION['email']); ?><input name="a_email" type="text" id="a_email" size="45" value="<?php echo ($_SESSION['email']); ?>" style="visibility : hidden;" /></td></tr><tr><td valign="top" bgcolor="#000055"><p>Reply:</p></td><td valign="top" bgcolor="#000055"> </td><td><textarea class="style" wrap="hard" name="a_answer" cols="80" rows="10" id="a_answer"></textarea></td></tr><tr><td> </td><td bgcolor="#000055"><p><input name="id" type="hidden" value="<?php echo $id; ?>"><input name="page" type="hidden" value="<?php echo $page; ?>"></p></td><td bgcolor="#000055"align="center"><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td></tr></table></td></form></tr></table></div></BODY></HTML>
  3. okay there was an improvement, it came up as<< First < Previous 1 Next > Last >>but the 'first' 'previous' and '1' are not links, and the next and last sent me to a "page cannot be displayed"
  4. okay let me try this, thanks again!
  5. well I got the free account at brinkster, it is a weird control panel but the asp codes are working so I will mess with it there i guessthanks for the info!
  6. thanks, is there any other way to run IIS besides off of the winxp cd? because my cd is destroyed
  7. I have been learning about PHP on my local machine. I have been using WAMP5 (windows apache mysql php5)I tried to start learning about ASP but it obveously does not support it..<html><body><%response.write("Hello World!")%></body></html>I tried that and saved it as test.aspand it returned a blank page.anyway.. how can I set up my computer so i can learn about ASP also ?please help, thanks!
  8. Well i think there was a few (')'s missing i put them in and the code didnt have errors, and the posts load, but there is still no next button.in the first line: $total_pages = $total_count / $per_page;where does that total_count variable come from?
  9. hey I think there might be a couple small syntax errors in that code and I am not sure how to fix it ;-(
  10. wow Thanks for taking the time to write all of that, I did not think it was going to be that complicated! I am not sure exactlywhere to put that code, buit I am going to mess with it now and see if I can get it working, thanks again!!
  11. i can get it to echo out a word when there is greater than 15 posts but I dont get how you do the link to the next page and then from there a previous one
  12. Thanks alot you guys, it is working as far as 15posts per page, I just need a little help understanding how to get the next / back buttons to showup / work when 15posts have come up. because right now it just posts the next posts to page=2 but it puts the user at page=1 when they post and also theres no indication that there are more posts on page 2. I am very greatfull for all the time you guys have taken to help me so far! if you can help me get some next / back buttons up to man that would be great!
  13. okay something new is happening atleast, its not giving me an error anymore.and it is only allowing 15 posts on the page, but it is not posting to a new page after thatany ideas? EDIT: wait I typed in page=2 on my url and the next posts are actually there! its looking like it will work, something is still missingbecause it doesnt bring me to page2 when I keep posting
  14. I actually wrote it like this when I got the error:$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id' LIMIT $start, $per_page";I just forgot to delete the limit part when I posted that!
  15. thanks for the info, I got this working the other night just like that.
  16. i do understand how to pass a variable to another page, and I understand how to process a form.my forum works already it just doesnt seperate posts on to different pages..did you read how I was making the page variable? and sending it to the viewtopic? was I doing that right?
  17. this is my main forum code also where you click on which topic to view: <?php// Start sessionsession_start();// Check if the user already is logged inif ((!isset( $_SESSION['loggedin'] )) || (!$_SESSION['loggedin'])) { header( 'Location: login.php' ); exit();}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE>MMA and BJJ message forum</TITLE> <META name="abstract" content=""> <META name="description" content=""> <META name="keywords" content=""> <META name="Revisit-After" content="10"> <META HTTP-EQUIV="Content-Language" content="EN"> <META name="distribution" content="global"> <link rel="stylesheet" type="text/css" href="forum.css"> </HEAD><BODY><div id="top"><?php if ((!isset( $_SESSION['loggedin'] )) || (!$_SESSION['loggedin'])) { echo "<p class=\"log\">Welcome Guest <a href=\"login.php\">Log In</a>"; } else { echo ("<p class=\"log\">Welcome ". ($_SESSION['user']) . " <a href=\"logout.php\">log out</a></p>"); } ?></div><div id="sitemap"><p><a class="menu" href="index.php" title="VikingBJJ home page">VikingBJJ.com</a></p></div><div id="forumbody"><?php$host="localhost"; // Host name $username="root"; // Mysql username $password="********"; // Mysql password $db_name="vikingbjj"; // Database name $tbl_name="mmabjj_question"; // Table name // Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");$pg = 1;$sql="SELECT * FROM $tbl_name ORDER BY id DESC";// OREDER BY id DESC is order result by descending $result=mysql_query($sql);?><table width="100%" border="0" bordercolor="#ffff00" align="center" cellpadding="3" cellspacing="1" bgcolor="#ffff00"><tr><td width="6%" align="center" bgcolor="#000055"><strong><p>#</p></strong></td><td width="53%" align="center" bgcolor="#000066"><strong><p>MMA & BJJ</p></strong></td><td width="15%" align="center" bgcolor="#000055"><strong><p>Views</p></strong></td><td width="13%" align="center" bgcolor="#000066"><strong><p>Replies</p></strong></td><td width="13%" align="center" bgcolor="#000055"><strong><p>Date/Time</p></strong></td></tr><?phpwhile($rows=mysql_fetch_array($result)){ // Start looping table row ?><tr><td align="center" bgcolor="#000044"><p><?php echo $rows['id']; ?></p></td><td VALIGN="middle" align="left" bgcolor="#000044"><a href="<?php echo "mmabjj_viewtopic.php?id=" . $rows['id'] ."&page=$pg"; ?>"><?php echo $rows['topic']; ?></a></td><td align="center" bgcolor="#000044"><p><?php echo $rows['view']; ?></p></td><td align="center" bgcolor="#000044"><p><?php echo $rows['reply']; ?></p></td><td align="center" bgcolor="#000044"><p><?php echo $rows['datetime']; ?></p></td></tr><?php// Exit looping and close connection }mysql_close();?><tr><td colspan="1" align="left" bgcolor="#000066"> </td><td colspan="1" align="center" bgcolor="#000066"><a href="mmabjj_newtopic.php"><p>Create New Topic</p> </a></td><td colspan="4" align="right" bgcolor="#000066"> </td></tr></table></div></BODY></HTML>
  18. no luck... it is returning this:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\vikingbjj\mmabjj_viewtopic.php on line 104am I suposed to have something setup in my database to get the page# ??
  19. when The user adds an answer it sends the variables here to this page..I think something needs to be done here also:<?phpinclude('safe.php');// Connect to server and select databse.mysql_connect("localhost", "root", "******")or die("cannot connect"); mysql_select_db("vikingbjj")or die("cannot select DB");// Get value of id that sent from hidden field $id=$_POST[id];// Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM mmabjj_answer WHERE question_id=$id";$result=mysql_query($sql);$rows=mysql_fetch_array($result);// add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) {$Max_id = $rows['Maxa_id']+1;}else {$Max_id = 1;}// get values that sent from form $a_name=$_POST['a_name'];$a_email=$_POST['a_email'];$a_answer=safe($_POST['a_answer']); $datetime=date("d/m/y H:i:s"); // create date and time // Insert answer $sql2="INSERT INTO mmabjj_answer(question_id, a_id, a_name, a_email, a_answer, a_datetime)VALUES($id, '$Max_id', '$a_name', '$a_email', '$a_answer', '$datetime')";$result2=mysql_query($sql2);if($result2){header("location:mmabjj_viewtopic.php?id=$id");// If added new answer, add value +1 in reply column $sql3="UPDATE mmabjj_question SET reply='$Max_id' WHERE id=$id";$result3=mysql_query($sql3);}else {echo "ERROR";}mysql_close();?>
  20. I will try this thanks.. I still do not think I am doing the page variable correctly!all I did to do that was on the main forum page.. i did this $pg = 1;and on the link where you click to view the topic i just did this:<a href="<?php echo "viewtopic.php?id=" . $row[id] . "&page="$pg"; >?>is that what I was suposed to do? or am I going about making page=1 show up in the URL all wrong?please help!!
  21. I tried changing the sql to:$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id' LIMIT {$start}, {$per_page}";when I do that it returns this:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\vikingbjj\mmabjj_viewtopic.php on line 104I have to not be doing something right when making a page variable.. thats the part I dont have a clue about!
  22. astralaaron

    session

    I am no expert on PHP, I am actually very new but I think what they are doing there is for people that do not have cookies enabled on their computers and SESSIONS cant be sent around... they are adding SID to their URL's like<a href="fdsa.php?' . SID . '"></a> if you go to http://www.phpvideotutorials.com/ this guy talks about it in his sessions and cookies lessontheres 13 lessons up there with some usefull stuff for us beginners! :-)then again I could be completely wrong about this!
  23. please explain how to make the page variable!
×
×
  • Create New...