Jump to content

mike12255

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mike12255

  1. Im creating a forum were 10 posts are showen per page, and at the moment im trying to take the number of posts and dirive how many pages should be shown. So i created this formula. were y is equal to the total number of pages. so: So the i expanded and simplified that equation: and in the end afteri finishe simplifying i forgot how i was using this equation and i got lost in my own math. Dont say this isnt related to php please because thisis the math that my code is going to run (the final equation) anyway anyone know what i was thinking when i did this? Y = the number of pages but I dont know howi figured out how to get the number of pages from the number of posts.
  2. I seemed to get it working, i was playing with the wrong line, but had the right code.
  3. I think your math is right cal, let me try that and get back to you
  4. I know i was talking to him about that and he said it wouldnt work for some reason, and regardless my problem still wont be fixed using that
  5. So i had the following lines: $page = $_GET['page'] * 10; $tolimit = 15; print "<table class='maintable'>"; print "<tr class='headline' color = 'white'><td width=20%>Author</td><td width=80%>Post</td></tr>"; $gettopic="SELECT * from forumtutorial_posts where postid='$id' AND area ='math' LIMIT $page,$tolimit" My whole idea of using the limit feature was to limit the amount of posts displayed on a page. My friend told me that anything multiplied by something in php is an int so he said: Which means that a string couldnt be entered protecting me from an sql injection. However I tried that with the url http://schoolworkanswers.com/message.php?id=22&catagory=math&page=1 however no posts showed up and im not sure why this happenings. Im guesing because i do Page 1 * 10 so its trying to start at the tenth post but i dont have a tenth post. Anyone have an opinion on how to change this to work better and still do what I want?
  6. I got the following table: $page = $_GET['page'] * 10; $tolimit = 10; print "<table class='maintable'>"; print "<tr class='headline' color = 'white'><td width=20%>Author</td><td width=80%>Post</td></tr>"; $gettopic="SELECT * from forumtutorial_posts where postid='$id' AND area ='math' LIMIT $page $tolimit"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); print "<tr class='mainrow'><td valign='top'>$gettopic3[author]</td><td vakign='top'>Last replied to at $gettopic3[showtime]<br><hr>"; //print "<A href='deletetopic.php?id=$id'><img src='images/edit-btn.gif' height='25'align='right'</a> "; $message=strip_tags($gettopic3['post']); $message=nl2br($message); print "$message<hr><br>"; if ($record['locked'] < 1 || ($session->isAdmin())){ print "<a href= 'reply.php?id=$id' ><img src='images/quote-btn.gif' height='25' align='right'></a>"; } print "</td></tr>"; $getreplies="Select * from forumtutorial_posts where parentid='$id' order by postid ASC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { print "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td vakign='top'>Last replied to at $getreplies3[showtime]<br><hr>"; $message=strip_tags($getreplies3['post']); $message=nl2br($message); print "$message<hr><br>"; if ($record['locked'] < 1 || ($session->isAdmin())){ print "<a href= 'reply.php?id=$id' ><img src='images/quote-btn.gif' height='25' align='right'></a>"; } } //print "</td></tr>"; print "</table>"; The Im getting the error that the following line is told to give: $gettopic2=mysql_query($gettopic) or die("Could not get topic"); The URL is I dont know what is wrong with my query when i change "id" to 22 and do sql in phpmyadmin it works.
  7. so i got this code: print "<tr class='mainrow'><td><A /thref='message.php?id=$getthreads3[postid]'>$getthreads3[title]</a><d><td>$getthreads3[author]</td><td>$getthreads3[numreplies]</td><td> <b>$getthreads3[lastposter]</b></tr></br> $name </td>"; and i need to add math=area to the url, how do i do it? the url is this line: print "<tr class='mainrow'><td><A /thref='message.php?id=$getthreads3[postid]'>$getthreads3[title]</a><d>
  8. I tried it and got this: thats the line thats printing the div tag.
  9. Im trying to place text under a topic title, just part of the post as a short desciprtion with the following code: $getthreads="SELECT * from forumtutorial_posts where parentid='0' AND `area`= 'math' order by lastrepliedto DESC"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $name = strip_tags($getthreads3[post]); if (strlen($name) > 20){ while (strlen($name) >6){ $name = substr($name,0,-1); } } print "<tr class='mainrow'><td><A href='message.php?id=$getthreads3[postid]'>$getthreads3[title]</a></td><td>$getthreads3[author]</td><td>$getthreads3[numreplies]</td><td> <b>$getthreads3[lastposter]</b></tr></br> $name </td>"; } print "</table>"; ?> Problem is i keep playing with this code and they text either ends up at the top of above all the topic titles, or they appear under the right topic title but are alinged right and i cant seem to fix it. Any suggestions??
  10. curse my bad vision, cant beleive i missed that, thanks. Going to get my glasses right away.
  11. o, i read that (thanks) and came up with this: $info = $_GET['id']; $nquery = "SELECT * FROM forumtutorial_posts WHERE postid = $info AND area = 'math'"; $result = mysql_query(nquery); while ($row = mysql_fetch_assoc($result)) { echo $row['title']; } and im getting this error: that line is but im not sure what my error is.
  12. I got the following bit of code: <td height="29" colspan="20" background="images/index_35.gif"><a href="math.php">Math Questions: <?php $info = $_GET['id']; $nquery = "SELECT * FROM forumtutorial_posts WHERE postid = $info AND area = 'math'"; echo mysql_query($nquery); ?></a></td> and it outputs the following: were it should output:
  13. If the above does not work, post your code and I may be able to help
  14. ok, it worked, thanks mates. Wasnt sure about the second WHERE and had no idea about the quotes
  15. I have the following line: <?php $query = "SELECT * FROM `phpforum_tutorial` WHERE `postid` = $id AND WHERE `area` = math"; ?> I dont recive an error from the query but i tried importing it into phpmyadmin and nothing came up, well an error did so i know i did the query wrong, anyone know my mistake?
  16. I got the following css: #box1{ color:#999999; font: normal 12px; background-color:#999999; } #box2{ color:#000000; font: normal 12px; background-color:#FFFFFF; } And the code for this page : http://www.schoolworkanswers.com/math.php is here: <?php print "<link rel='stylesheet' href='style.css' type='text/css'>"; print ("<A href='post.php'>New Topic</a> -"); print ("<A href='register.php'>Register</a> -"); //print("<A href='main.php'>Control Panel</a> ");// correct way print "<table class='maintable'>"; print "<tr class='headline'><td width=50%>Topic</td><td width=20%>Topic Starter</td><td>Replies</td><td> Last replied by</td></tr>"; $getthreads="SELECT * from forumtutorial_posts where parentid='0' order by lastrepliedto DESC"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); print "<tr class='mainrow'><td><A href='message.php?id=$getthreads3[postid]'>$getthreads3[title]</a></td><td>$getthreads3[author]</td><td>$getthreads3[numreplies]</td><td> <b>$getthreads3[lastposter]</b></td></tr>"; } print "</table>"; ?> I want it so it alternates that the first post has a grey background and the second a white and the third a grey and the fourth a white ect ect im not sure how to do it with those two codes though.
  17. ok thanks, ill add it my way for now and play around with your way. thanks again.
  18. so what you wrote is the equivalent of what i wrote?
  19. your the one that marks it as solved you click the botton at the bottom of the page...
  20. yeah, i found the one i was missing and added it in though, but still got errors as can be see at (http://sgi-clan.info/gnomes/index.php under the "some sponsers" header) my problem is im still only getting 1 caption to appear and all three urls that appear are the same. + before the first image/caption appears it shows this: Here is the code for the table: <table width="100%" border="0" cellpadding="0" cellspacing="0" class="blackbg"> <tr> <td><img src="images/black3.jpg" width="3" height="3" /></td> <td align="right"><img src="images/black4.jpg" width="3" height="3" /></td> </tr> </table> </td> <td width="190"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/modifiedfinalsliced_138.gif" width="177" height="25" /></td> </tr> <tr> <td class="sponsorbg"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="5"> <tr> <td align="center"> </td> </tr> <tr> <?php $randoms = array(); $start =1; $total =11; while (count($randoms) < 3) { $random = mt_rand($start,$total); if (!in_array($random, $randoms)) { $randoms[] = $random; } } $captions = array("RBC","Prodomax","Liews Motors","Advanced Motion Controls","Burnside","TD Canada Trust","Reinhart","SCDSB","ARO","Stayner Lions","test","ComTek"); $urls = array("http://www.royalbank.com", "http://prodomax.com/","http://www.lewismotorsinc.com/","http://a-m-c.com/","http://www.rjburnside.com/","http://tdcanadatrust.com","http://www.reinhartfoods.com/", "http://www.scdsb.on.ca/", "http://www.aronet.com/", "http://www.lionsclubs.org/","test","http://www.comtekcomputers.com/"); for ( $i = 0; $i < 3; $i++){ $caps = $captions[$randoms[$i]];; $img = $urls[$randoms[$i]]; } ?> <td align="center"><img src="images/random/<?php echo $random.".jpg" ?>" height="25"/> </td> </tr> <tr> <td align="center"><a href="<?php echo $img ?>" class="link"><?=$caps?></a></td> </tr> <tr> <td align="center" class="dotline"> </td> </tr> <tr> <td align="center"><img src="images/random/<?php echo $randoms.".jpg" ?>" height="25" /></td> </tr> <tr> <td align="center"><a href="<?php echo $img ?>" class="link"><?php echo $caps ?></a></td> </tr> <tr> <td align="center" class="dotline"> </td> </tr> <tr> d align="center"><img src="images/random/<?php echo $randoms.".jpg" ?>" height="25" /></td> </tr> <tr> <td align="center"><a href="<?php echo $img ?>" class="link"><?php echo $caps ?></a></td> </tr> </table></td> </tr>
  21. So i got the following error: im not sure what the error means, but i know something is wrong because only one image appears and all the words are the same. <?php $randoms = array(); $start =1; $total =11; while (count($randoms) < 3) { $random = mt_rand($start,$total); if (!in_array($random, $randoms)) { $randoms[] = $random; } } $captions = array("RBC","Prodomax","Liews Motors","Advanced Motion Controls","Burnside","TD Canada Trust","Reinhart","SCDSB","ARO","Stayner Lions","test","ComTek"); $urls = array("http://www.royalbank.com", "http://prodomax.com/","http://a-m-c.com/","http://www.rjburnside.com/","http://tdcanadatrust.com","http://www.reinhartfoods.com/", "http://www.scdsb.on.ca/", "http://www.aronet.com/", "http://www.lionsclubs.org/","test","http://www.comtekcomputers.com/"); for ( $i = 0; $i < 3; $i++){ $caps = $captions[$randoms[$i]];; $img = $urls[$randoms[$i]]; } ?>
  22. you can learn it here: http://ca2.php.net/manual/en/function.mail.php
  23. hey thanks PFMaBiSmAd i've never heard of that, im sure it'll help me too!
  24. you could try this: $newitems = mysql_query ("SELECT * FROM ply ORDER BY id DESC LIMIT 1") Might have to be asc but im pretty sure its desc btw no promises on that im not the best at mysql
×
×
  • 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.