andrew_biggart
Members-
Posts
363 -
Joined
-
Last visited
-
Days Won
1
Everything posted by andrew_biggart
-
Basically what I am trying to do is display all Categories that my shop has which are listed in the Category table. I can Get this section working fine. But then when I try and Count the number of items each category has I run into problems. Im trying to count the number of items each category has by the Item_id. At the moment I am getting a syntax error. Can anyone Help please? <table class="shop_left"> <tr> <td class="shop_left_ho">Categories</td> </tr> <?php ini_set("display_errors", "1"); error_reporting(E_ALL); include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_shop_categories ORDER BY Cat_id ASC " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ $Category = $rows['Category']; // Retrieve data from database $sql2 = "SELECT count(Item_id) as itemcount FROM biggartfp9_shop_itemst WHERE Category='$Category' "; $result2 = mysql_query($sql2); $rows2 = mysql_fetch_assoc($result2); if($rows2['itemcount'] != 0) { $Catnum = $rows2['itemcount']; } else { $Catnum == 0]; } ?> <tr> <td class="shop_left_subh"> <a href="shop_categories.php?cat_id=<? echo $rows['Category']; ?>" class="shop_filter"><?php echo $rows['Category']; ?> <?php echo $Catnum; ?> </a> </td> </tr> <? // close while loop } // close connection mysql_close(); ?> </table>
-
Thank you I will use your advise! I had been staring at it so long I couldn't spot that... Just needed a fresh pair of eyes so thank you!
-
Ok I have a form which is only displayed when ever the user is logged in, I want a profile thumb beside the form and for some reason the image is not being displayed even though the same piece of code works on other bits of the site, is there something interfering with the code? <form method="post" action="forum_comment.php?Post_id=<?php echo $post_id; ?>"> <?php // close connection mysql_close(); ?> <?php $username=$_SESSION['myusername']; include("config.php"); // Retrieve data from database $sql="SELECT Profile_picture FROM biggartfp9_user_infot Where Username = '$username' " ; $result=mysql_query($sql); $row = mysql_fetch_array($result); $profile_picture = $row['Profile_picture']; if(isset($_SESSION['myusername'])) { echo " <table cellpadding='0' cellspacing='0' class='acc_status_table'> <tr> <td class='forum_ad'>Add a Comment</td> </tr> <tr> <td class='acc_status_feed'> <table> <tr> <td> <table cellpadding='0' cellspacing='0'> <tr> <td class='forum_view_cat' style='width: 50px' valign='top'></td> <td class='forum_comments_wrapper'> <table style='width: 100%'> <tr> <td class='forum_reply' colspan='2'>Reply ?</td> </tr> <tr> <td class='forum_comments_comment' colspan='2'> <textarea class='forum_reply_text'cols='20' name='replycomment' rows='2'></textarea> </td> </tr> <tr> <td class='forum_reply_max'>Max 2000 Characters</td> <td class='forum_reply_input'><input class='forum_reply_submit' name='Submit1' type='submit' value='Post Reply' /></td> </tr> </table> </td> <td class='forum_comments_spacer'> </td> <td class='forum_view_pic' style='width: 50px' valign='top'> <img src='../Profile_pics/". $Profile_picture ."' style='width:50px;' /> </td> </tr> </table> <br /> </td> </tr> </table> </td> </tr> </table> "; } else{ } ?> </form>
-
Ok Ken I do apologise for that, I am only a beginner and I am still learning so please do bare with me and thankyou for your patience, are you able to give me any advice as to where I am going wrong? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Latest Thread</title> </head> <body> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)) $pic_username = $rows['Post_username']; $pic_query = "SELECT Profile_picture FROM biggartfp9_user_infot WHERE Username = '$pic_username'"; $pic_result = mysql_query($pic_query) or die('Error : ' . mysql_error()); $pic_row = mysql_fetch_array($pic_result); $profile_picture = $pic_row['Profile_picture']; { ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"> <a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_picture/$profile_picture' style='width:50px; height:50px;' />";?></a> </td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<?php echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<?php echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <?php // close while loop } // close connection mysql_close(); ?> </td> </tr> </table> </body> </html> </html>
-
Now the thread information is being displayed but the profile picture is not, Im obviously close to getting it working but just need a little nudge in the right direction.... Any ideas anyone? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Latest Thread</title> </head> <body> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); $pic_username = $rows['Post_username']; $pic_query = "SELECT Profile_picture FROM biggartfp9_user_infot WHERE Username = '$pic_username'"; $pic_result = mysql_query($pic_query) or die('Error : ' . mysql_error()); $pic_row = mysql_fetch_array($pic_result); $profile_picture = $pic_row['Profile_picture']; // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)) { ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"> <a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_picture/$profile_picture' style='width:50px;' />";?></a> </td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<? echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<? echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <? // close while loop } // close connection mysql_close(); ?> </td> </tr> </table> </body> </html>
-
Right I have changed it to the code below and it is now displaying one thread with the profile picture but doesn't display the thread data, I am getting any closer? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Latest Thread</title> </head> <body> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)) $pic_username = $rows['Post_username']; $pic_query = "SELECT Profile_picture FROM biggartfp9_user_infot WHERE Username = '$pic_username'"; $pic_result = mysql_query($pic_query) or die('Error : ' . mysql_error()); $pic_row = mysql_fetch_array($pic_result); $profile_picture = $pic_row['Profile_picture']; { ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"> <a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_picture/$profile_picture' style='width:50px; height:50px;' />";?></a> </td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<? echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<? echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <? // close while loop } // close connection mysql_close(); ?> </td> </tr> </table> </body> </html>
-
I need help with this please, I cant get my head around the logic at all. I have two databases, a user database containing username, user id, profile picture etc and then I have a thread database for the forum posts containing all of the thread info I.e the post id, post username and post data. What I am aiming to do is i have a while loop on the threads page to loop through all the forum posts and display them. I can get it to display all the posts this is not the problem. The problem is I want it to get all the posts and add them to an array once it has done that I want it to use all of the post username's in the area to get the relevant profile pictures for each user that has made a thread in the forum and display the correct profile picture from the user information table. I have tries several methods but cannot seem to get this working at all, below is one of the solutions I have tried but it doesn't display any of the information at all. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Latest Thread</title> </head> <body> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)) $pic_username = $rows; $pic_query = "SELECT Profile_picture FROM biggartfp9_user_infot WHERE Username = '$pic_username'"; $pic_result = mysql_query($pic_query) or die('Error : ' . mysql_error()); $pic_row = mysql_fetch_array($result); $profile_picture = $row['Profile_picture']; { ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"> <a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_picture/$profile_picture' style='width:50px; height:50px;' />";?></a> </td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<? echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<? echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <? // close while loop } // close connection mysql_close(); ?> </td> </tr> </table> </body> </html>
-
Yea I have removed it for the purpose of posting it here!
-
Ok yea that is working but again the only bit I cannot seem to get working is the adding to the database, I am writing the query wrong? <?php include('upload_class.php'); //Directory to the class $username=$_SESSION['myusername']; $query = "SELECT User_id FROM biggartfp9_user_infot WHERE Username = '$username'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result); $User_id = $row['User_id']; if(isset($_POST['upload'])){ if (isset($_FILES['photo']) && $_FILES['photo']['error'] != 4) { $img = new ImageManip($_FILES['photo'], 10000000000); // 1000000000 is the max file size $img->set_size(100,100); //Replace 400, 400 with the size you wish to resize the image to. $file = "../Profile_pics/" . time() . "-" . $_FILES['photo']['name']; $img->save($file); //Save to database $query = mysql_query("UPDATE biggartfp9_user_infot SET Profile_picture = '$file' WHERE User_id = '$User_id'") or trigger_error("Query failed: ".mysql_error()); } } echo "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"> <label for=\"file\">Filename:</label> <input type=\"file\" name=\"photo\" id=\"photo\" /> <br /> <input type=\"submit\" name=\"upload\" value=\"Submit\" /> </form>"; ?>
-
I am trying to built a php upload script to allow users to upload profile pictures. I want it to do the following... 1. upload the image 2 . resize original image without distorting it 2. store the file name in the database 3. create and save a thumbnail So far I have got the following code which successfully uploads the image but doesn't change the file name in the database any ideas why and also what step do I take next? Any help of tutorials would be appreciated thanks. <?php $host="xxxx"; // Host name $db_username="xxxx"; // Mysql username $db_password="xxxx"; // Mysql password $db_name="xxxx"; // Database name // Connect to server and select databse. mysql_connect("$host", "$db_username", "$db_password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $username=$_SESSION['myusername']; $query = "SELECT User_id FROM biggartfp9_user_infot WHERE Username = '$username'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result); $User_id = $row['User_id']; $uploadDir = '../Profile_pics/'; if(isset($_POST['submit'])) { $fileName = $_FILES['file']['name']; $tmpName = $_FILES['file']['tmp_name']; $fileSize = $_FILES['file']['size']; $fileType = $_FILES['file']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading!"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $result = mysql_query("UPDATE biggartfp9_user_infot SET Profile_picture='$fileName' WHERE User_id='$User_id'") or die(mysql_error()); echo "$fileName <h1>Success!</h1> You have successfully added a Profile Photo. <a href=profile.php?username=$User_id>Return to Profile</a><br><br><br>"; } else { echo" <form name=Image enctype=multipart/form-data method=POST> <table cellspacing=2 cellpadding=2 border=0> <tr><td>Image: </td><td><input type=file name=file accept=image/gif, image/jpeg, image/x-ms-bmp, image/x-png size=26 class=textbox /></td></tr> <tr><td> </td><td><input type=submit name=submit value=Upload class=button /></td></tr></table> </form><br>"; } ?>
-
Ok I have written this script to upload images and auto thumbnail them but i am getting the white screen i cannot spot the syntax error please help. <?php $images_location = "../Profile_pics/"; $thumbs_location = "../Profile_thumbs/"; $thumb_width = 50; $maximum_size = 5000000; $results = "Click browse to locate your profile picture!"; require ("uploader.php"); if ($_POST) { //checking for image if ($_FILES['image']['name'] == "") { $results = "Please select the image you want to upload!" ; } //start of upload else { $size = filesize($_FILES['image']['tmp_name']); $filename = stripslashes($_FILES['image']['name']); $extension = get_image_extension($filename); if($size >$maximum_size) { $results = "Your Image is to big, please selecta smaller image!"; else // allow only certain extensions if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $results = "Invalid image extension, images can only be .jpg, .jpeg, .png or .gif!"; } //generates random name else $image_random_name = random_name(15).".".$extension; $copy = @copy($_FILES['image']['tmp_name'], $images_location.$image_random_name); if (!$copy) { $results = "There was a problem uploading your image, please try again!"; else { create_thumbnail($images_location.$image_random_name,$thumbs_location.$image_random_name, $thumb_width); $results = "Your profile picture has been uploaded!"; } } } } ?>
-
Help with IF and ELSE statement confusion
andrew_biggart replied to andrew_biggart's topic in PHP Coding Help
ok sorted the syntax error, but now even when i am logged in it shows the form but also the the you need to be logged in echo. And also the second if statement is not working. Hear is the new code. <?php if(isset($_SESSION['myusername'])) { echo " <form method='post' action='#Profile_comment'> <table class='pro_addcomment'> <tr> <td class='pro_add_h' colspan='3'>Add a profile comment</td> </tr> <tr> <td class='pro_add_text' colspan='2'> <textarea name='profilecomment' class='pro_add_input'></textarea> </td> <td rowspan='2' class='pro_view_pic' valign='top'> <img src='../Profile_pics/". $image ."' style='width:50px; height:50px;' /> </td> </tr> <tr> <td class='pro_add_max'>Max 200 characters</td> <td class='pro_add_button'> <input class='acc_alerts_accept' name='add_comment' type='submit' value='Add Comment' /> </td> </tr> </table> </form> "; if(isset($_POST['add_comment'])){ include("config.php"); $Comment_user=$_GET['username']; $Comment_sender=$_SESSION['myusername']; $Comment_comment=$_POST['profilecomment']; $Profile_picture=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_profile_comments_tempt (Comment_user, Comment_sender, Comment_date, Comment_content, Profile_picture)VALUES('$Comment_user','$Comment_sender', NOW(),'$Comment_comment', '$Profile_picture')"; $result=mysql_query($sql); if($result){ header("location:profile.php?username=$Comment_user#Profile_comment"); } else{ } } else{ echo"<h1 class=status_red>Please Login to submit a comment!</h1>"; } } ?> -
Help with IF and ELSE statement confusion
andrew_biggart replied to andrew_biggart's topic in PHP Coding Help
Well at the minute im getting a syntax error which I cannot spot, and then i can test it and let you know -
Ok what I am trying to do is create a script which first checks if the user is logged in, if they are display a comment form if they are not do not display the form. Next once that has been checked I want to check if the user has submitted the form, if they have run the insert mysql statement and if they havnt do nothing. I have messed about with it so much and I can get certain parts working but not others, Please help me get my head around it... Here is what I have. <?php if(isset($_SESSION['myusername'])) { echo " <form method='post' action='#Profile_comment'> <table class='pro_addcomment'> <tr> <td class='pro_add_h' colspan='3'>Add a profile comment</td> </tr> <tr> <td class='pro_add_text' colspan='2'> <textarea name='profilecomment' class='pro_add_input'></textarea> </td> <td rowspan='2' class='pro_view_pic' valign='top'> <img src='../Profile_pics/". $image ."' style='width:50px; height:50px;' /> </td> </tr> <tr> <td class='pro_add_max'>Max 200 characters</td> <td class='pro_add_button'> <input class='acc_alerts_accept' name='add_comment' type='submit' value='Add Comment' /> </td> </tr> </table> </form> "; if(isset($_POST['add_comment'])){ include("config.php"); $Comment_user=$_GET['username']; $Comment_sender=$_SESSION['myusername']; $Comment_comment=$_POST['profilecomment']; $Profile_picture=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_profile_comments_tempt (Comment_user, Comment_sender, Comment_date, Comment_content, Profile_picture)VALUES('$Comment_user','$Comment_sender', NOW(),'$Comment_comment', '$Profile_picture')"; $result=mysql_query($sql); if($result){ header("location:profile.php?username=$Comment_user#Profile_comment"); } else{ } } else{ echo"<h1 class=status_red>Please Login to submit a comment!</h1>"; } ?>
-
Redirecting to thread a user has just submitted
andrew_biggart replied to andrew_biggart's topic in PHP Coding Help
Ok i have did abit of error checking and i can echo the result as a link which works, so the problem is with the redirecting... This is the whole page is there anything that would conflict with the redirection? <?php session_start(); if(isset($_SESSION['myusername'])) { } else{ header("location:register.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <!-- #BeginTemplate "default.dwt" --> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <!-- #BeginEditable "doctitle" --> <title>Home | Sign In | Register | Cont</title> <!-- #EndEditable --> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link href="../css/layout.css" rel="stylesheet" type="text/css" /> <link href="../css/styles.css" rel="stylesheet" type="text/css" /> <link href="../css/content.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../js/jquery-latest.js"></script> <script type="text/javascript" src="../js/scrolltopcontrol.js"></script> <script type="text/javascript" src="../js/dropdown_menu.js"></script> <style type="text/css"> .style1 { border-width: 0px; } a { color: #C2E115; } </style> </head> <body> <div id="wrapper"> <a name="top_page" id="top_page"></a> <div id="masthead"> <form method="post"> <table class="masthead" cellpadding="0" cellspacing="0" style="width: 740px; height: 63px"> <tr> <td class="homelink" rowspan="2"> <a href="default.php"><img alt="iloveartonline | Homepage" height="63" src="../images/homelink_bg.png" width="450" class="style1" /></a> </td> <td class="subnav"> <?php if(isset($_SESSION['myusername'])) { echo " <a href='default.php'>Home</a> | <a href='my_account.php'>Account</a> | <a href='basket.php'>Shopping Cart</a> | <a href='logout.php'>Logout</a> "; } else{ echo " Welcome Guest, You are not Logged in. Please <a href='register.php'>Login</a> or <a href='register.php'>Register</a>. "; } ?> </td> </tr> <tr> <td class="searchbox"> <table> <tr> <td> <input class="search"name="search" type="text" value="Search our site" /></td> <td><a href="search_site.php"> <img alt="" class="style1" height="20" src="../images/searchbutton_bg.png" width="20" /></a></td> </tr> </table> </td> </tr> </table> </form> </div> <div id="top_nav_div"> <ul class="topnav"> <li> <a href="#">Artists</a> <ul class="subnav"> <li class="top"><a href="#">Search Artists</a></li> <li class="top"><a href="#">A - E</a></li> <li class="top"><a href="#">F - J</a></li> <li class="top"><a href="#">K - O</a></li> <li class="top"><a href="#">P - T</a></li> <li class="bottom"><a href="#">U - Y</a></li> </ul> </li> <li> <a href="#">Galleries</a> <ul class="subnav"> <li class="top"><a href="#">Search Images</a></li> <li class="top"><a href="#">A - E</a></li> <li class="top"><a href="#">F - J</a></li> <li class="top"><a href="#">K - O</a></li> <li class="top"><a href="#">P - T</a></li> <li class="bottom"><a href="#">U - Y</a></li> </ul> </li> <li> <a href="#">Art News</a> <ul class="subnav"> <li class="top"><a href="#">Search News</a></li> <li class="top"><a href="#">Latest News</a></li> <li class="bottom"><a href="#">Most Popular</a></li> </ul> </li> <li> <a href="forum_latest.php">Forum</a> <ul class="subnav"> <li class="top"><a href="#">Search Forum</a></li> <li class="top"><a href="forum_latest.php">View Forum</a></li> <li class="top"><a href="forum_add.php">Add a Topic</a></li> <li class="bottom"><a href="forum_mypost.php">My Topics</a></li> </ul> </li> <li> <a href="#">Shop</a> <ul class="subnav"> <li class="top"><a href="#">Search Shop</a></li> <li class="top"><a href="#">Visit Shop</a></li> <li class="top"><a href="#">Sell Art</a></li> <li class="bottom"><a href="#">View Art</a></li> </ul> </li> <li> <a href="#">Contests</a> <ul class="subnav"> <li class="bottom"><a href="#">Coming Soon</a></li> </ul> </li> <li> <a href="my_account.php">Account</a> <?php $username=$_SESSION['myusername']; if(isset($_SESSION['myusername'])) { echo " <ul class='subnav'> <li class='top'><a href='profile.php?username=$username'>View Profile</a></li> <li class='top'><a href='my_alerts.php'>View Alerts</a></li> <li class='top'><a href='my_messages.php'>View messages</a></li> <li class='top'><a href='view_blog.php'>View Blog</a></li> <li class='top'><a href='my_portfolio'>View Pieces</a></li> <li class='bottom'><a href='logout.php'>Logout</a></li> </ul> "; } else{ echo " <ul class='subnav'> <li class='bottom'><a href='register.php'>Login or Register</a></li> </ul> "; } ?> </li> <li> <a href="#">Upload</a> <ul class="subnav"> <li class="top"><a href="#">Upload Art</a></li> <li class="top"><a href="#">Upload Article</a></li> <li class="bottom"><a href="#">Upload Link</a></li> </ul> </li> <li> <a href="#">Contact</a> </li> </ul> </div> <!-- #BeginEditable "body" --> <div id="container"> <div id="left_col"> <br /> <table class="forum_left_col"> <tr> <td class="forum_admin"><a href="forum_admin.php" class="forum_admin">AdMiN's Thread's</a></td> </tr> <?php include("config.php"); require("functions.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst WHERE Post_username='AdMiN' ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <tr> <td class="forum_submenu"> <a href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>" class="forum_subs"><? short_description($rows['Post_subject']); ?></a> </td> </tr> <? // close while loop } // close connection mysql_close(); ?> </table> <br /> <table class="forum_left_col"> <tr> <td class="forum_latest"><a href="forum_latest.php" class="forum_latest">Latest Thread's</a></td> </tr> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10" ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <tr> <td class="forum_submenu"> <a href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>" class="forum_subs"><? short_description($rows['Post_subject']); ?></a> </td> </tr> <? // close while loop } // close connection mysql_close(); ?> </table> <br /> <table class="forum_left_col"> <tr> <td class="forum_popular"><a href="forum_popular.php" class="forum_mostpopular">Popular Thread's</a></td> </tr> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 10" ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <tr> <td class="forum_submenu"> <a href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>" class="forum_subs"><? short_description($rows['Post_subject']); ?></a> </td> </tr> <? // close while loop } // close connection mysql_close(); ?> </table> <br /> <table class="forum_left_col"> <tr> <td class="forum_my"><a href="forum_mypost.php" class="forum_myposts">My Thread's</a></td> </tr> <?php include("config.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst WHERE Post_username='$username' ORDER BY Post_id DESC LIMIT 10 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <tr> <td class="forum_submenu"> <a href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>" class="forum_subs"><? short_description($rows['Post_subject']); ?></a> </td> </tr> <? // close while loop } // close connection mysql_close(); ?> </table> <br /> <table class="forum_left_col"> <tr> <td class="forum_add"><a href="forum_add.php" class="forum_add">Add a Thread</a></td> </tr> <tr> <td> <a href="forum_add.php"> <img class="forum_add_post" alt="" height="94" src="../images/tell_your_stories.png" width="150"/></a></td> </tr> </table> <br /> </div> <div id="page_content"> <br /> <form method="post" action="#"> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_ad">Add a Topic</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); if(isset($_POST['add_topic'])){ $Post_username=$_SESSION['myusername']; $Post_subject=$_POST['Post_subject']; $Post_message=$_POST['Post_message']; $Post_tags=$_POST['Post_tags']; $Post_type=$_POST['Post_type']; $Post_pp=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_forum_threadst (Post_username, Post_pp, Post_date, Post_subject, Post_message, Post_tags, Post_type)VALUES('$Post_username', '$Post_pp', NOW(), '$Post_subject', '$Post_message', '$Post_tags', '$Post_type')"; $result=mysql_query($sql); if($result){ $Post_id = mysql_insert_id(); header("location:forum_view.php?Post_id=$Post_id"); } else{ echo "<h1 class=status_red>Unfortunitly there has been a problem, Please try and resubmit your thread.</h1>"; }; // close connection mysql_close(); } else{ } ?> <table> <tr> <td> <table cellpadding="0" cellspacing="0"> <tr> <td rowspan="2" class="forum_view_cat" style="width: 50px" valign="top"></td> <td class="forum_add_top"> <table style="width: 100%"> <tr> <td class="forum_add_h">Topic</td> <td class="forum_add_max">Max 50 Characters</td> </tr> <tr> <td colspan="2" class="forum_add_inputs"><input class="forum_add_input" name="Post_subject" type="text"/></td> </tr> </table> </td> <td rowspan="2" class="forum_view_pic" style="width: 65px" valign="top"></td> </tr> <tr> <td class="forum_add_bot"> <table style="width: 100%"> <tr> <td class="forum_add_h">Message</td> <td class="forum_add_max">Max 2000 Characters</td> </tr> <tr> <td colspan="2" class="forum_add_inputs"><textarea class="forum_add_text" cols="20" name="Post_message" rows="2"></textarea></td> </tr> <tr> <td class="forum_add_h">Tags</td> <td class="forum_add_max">Max 200 Characters</td> </tr> <tr> <td colspan="2" class="forum_add_inputs"><input class="forum_add_input" name="Post_tags" type="text"/></td> </tr> <tr> <td colspan="2" class="forum_add_key">Separate keywords with a comma</td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <table> <tr> <td><select name="Post_type" style="width: 117px"> <option>ILoveArt</option> </select> <input name="add_topic" type="submit" value="submit"/></td> </tr> </table> </form> <br /> </div> </div> <!-- #EndEditable --> <div id="footer"> <div id="footer_nav"> <table> <tr> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_a">Artists</td> </tr> <tr> <td class="f_subnav">Search Artists</td> </tr> <tr> <td class="f_subnav">A - E</td> </tr> <tr> <td class="f_subnav">F - J</td> </tr> <tr> <td class="f_subnav">K - O</td> </tr> <tr> <td class="f_subnav">P - T</td> </tr> <tr> <td class="f_subnav">U - Y</td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_g">Galleries</td> </tr> <tr> <td class="f_subnav">Search Images</td> </tr> <tr> <td class="f_subnav">A - E</td> </tr> <tr> <td class="f_subnav">F - J</td> </tr> <tr> <td class="f_subnav">K - O</td> </tr> <tr> <td class="f_subnav">P - T</td> </tr> <tr> <td class="f_subnav">U - Y</td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_an">Art News</td> </tr> <tr> <td class="f_subnav">Search News</td> </tr> <tr> <td class="f_subnav">Latest News</td> </tr> <tr> <td class="f_subnav">Most Popular</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_f">Forum</td> </tr> <tr> <td class="f_subnav">Search Forum</td> </tr> <tr> <td class="f_subnav">View Forum</td> </tr> <tr> <td class="f_subnav">Add a Topic</td> </tr> <tr> <td class="f_subnav">My Topics</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_s">Shop</td> </tr> <tr> <td class="f_subnav">Search Shop</td> </tr> <tr> <td class="f_subnav">View Shop</td> </tr> <tr> <td class="f_subnav">View Art</td> </tr> <tr> <td class="f_subnav">Sell Art</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_c">Contests</td> </tr> <tr> <td class="f_subnav">Coming Soon</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_ac">Account</td> </tr> <?php $username=$_SESSION['myusername']; if(isset($_SESSION['myusername'])) { echo " <tr> <td class='f_subnav'>View Profile</td> </tr> <tr> <td class='f_subnav'>View Alerts</td> </tr> <tr> <td class='f_subnav'>View Messages</td> </tr> <tr> <td class='f_subnav'>View Blog</td> </tr> <tr> <td class='f_subnav'>View Pieces</td> </tr> <tr> <td class='f_subnav'>Logout</td> </tr> "; } else{ echo " <tr> <td class='f_subnav'>Register</td> </tr> "; } ?> </table> </td> <td class="f_nav" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_u">Upload</td> </tr> <tr> <td class="f_subnav">Upload Art</td> </tr> <tr> <td class="f_subnav">Upload Article</td> </tr> <tr> <td class="f_subnav">Upload Link</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> <td class="f_nav_e" style="width: 86px; height: 200px" valign="top"> <table> <tr> <td class="f_header_co">Contact</td> </tr> <tr> <td class="f_subnav">Contact Us</td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> <tr> <td class="f_subnav_e"></td> </tr> </table> </td> </tr> </table> </div> </div> </div> </body> <!-- #EndTemplate --> </html> -
Redirecting to thread a user has just submitted
andrew_biggart replied to andrew_biggart's topic in PHP Coding Help
Ok I got rid of that problem with the error message being displayed, silly mistake on my behalf. Just cant get my head around what to do next?? <?php include("config.php"); if(isset($_POST['add_topic'])){ $Post_username=$_SESSION['myusername']; $Post_subject=$_POST['Post_subject']; $Post_message=$_POST['Post_message']; $Post_tags=$_POST['Post_tags']; $Post_type=$_POST['Post_type']; $Post_pp=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_forum_threadst (Post_username, Post_pp, Post_date, Post_subject, Post_message, Post_tags, Post_type)VALUES('$Post_username', '$Post_pp', NOW(), '$Post_subject', '$Post_message', '$Post_tags', '$Post_type')"; $result=mysql_query($sql); if($result){ $Post_id = mysql_insert_id(); header("Location: forum_view.php?Post_id=$Post_id"); } else{ echo "<h1 class=status_red>Unfortunitly there has been a problem, Please try and resubmit your thread.</h1>"; }; // close connection mysql_close(); } else{ } ?> -
Redirecting to thread a user has just submitted
andrew_biggart replied to andrew_biggart's topic in PHP Coding Help
Ok that has made me get my head around it alittle more but it still isnt working, problem one is that i get the error echo, and problem 2 is there is no redirect. This is what i changed it to. <?php include("config.php"); if(isset($_POST['add_topic'])){ $Post_username=$_SESSION['myusername']; $Post_subject=$_POST['Post_subject']; $Post_message=$_POST['Post_message']; $Post_tags=$_POST['Post_tags']; $Post_type=$_POST['Post_type']; $Post_pp=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_forum_threadst (Post_username, Post_pp, Post_date, Post_subject, Post_message, Post_tags, Post_type)VALUES('$Post_username', '$Post_pp', NOW(), '$Post_subject', '$Post_message', '$Post_tags', '$Post_type')"; $result=mysql_query($sql); if($result){ $Post_id = mysql_insert_id(); header("Location: forum_view.php?Post_id=$Post_id"); } // close connection mysql_close(); } else{ echo "<h1 class=status_red>Unfortunitly there has been a problem, Please try and resubmit your thread.</h1>"; }; ?> -
Hi there basically what I would like to do is when ever a user submits a thread on my forum instead of echo"your thread has been submitted" I would like for them to be redirected to the thread that they just submitted. I know that i need to do an sql statement to find out what the Post_id was but i have no idea where to start, can anyone give me any tips or point me in the right direction? Thanks This is the current submit thread file that I am using. <?php include("config.php"); if(isset($_POST['add_topic'])){ $Post_username=$_SESSION['myusername']; $Post_subject=$_POST['Post_subject']; $Post_message=$_POST['Post_message']; $Post_tags=$_POST['Post_tags']; $Post_type=$_POST['Post_type']; $Post_pp=$_SESSION['myavatar']; $sql="INSERT INTO biggartfp9_forum_threadst (Post_username, Post_pp, Post_date, Post_subject, Post_message, Post_tags, Post_type)VALUES('$Post_username', '$Post_pp', NOW(), '$Post_subject', '$Post_message', '$Post_tags', '$Post_type')"; $result=mysql_query($sql); if($result){ echo "<h1 class=status_green>Your Post has been added successfully</h1>"; } // close connection mysql_close(); } else{ echo "<h1 class=status_red>Unfortunitly there has been a problem, Please try and resubmit your thread.</h1>"; }; ?>
-
I was having the same problem earlier using this tutorial, http://www.phpeasystep.com/phptu/29.html so you might want to try at this way as I got it working pretty easily. Just a suggestion
-
Should this work? I thought this is the right way to do it but i am receiving no output from the database. <br /> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_h">Thread Filter</td> </tr> <tr> <td class="acc_status_feed"> <table> <tr> <td><a class="forum_filter" href="forum_filter.php?id=ILoveArt">ILoveArt</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Artists">Artists</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Artwork">Artwork</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Galleries">Galleries</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Contests">Contests</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Love | Hate">Love | Hate</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Rant | Moan">Rant | Moan</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Whatever">Whatever</a></td> <td><a class="forum_filter" href="forum_filter.php?id=Problem">Problem</a></td> </tr> </table> </td> </tr> </table> <br /> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php /* Place code to connect to your DB here. */ include('config.php'); // include your code to connect to DB. $tbl_name="biggartfp9_forum_threadst"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 3; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "forum_pagetest.php"; //your file name (the name of this file) $limit = 5; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>"; else $pagination.= "<span class=\"disabled\">« previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>"; else $pagination.= "<span class=\"disabled\">next »</span>"; $pagination.= "</div>\n"; } ?> <?php while($row = mysql_fetch_array($result)) { ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"><a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_thumbs/". $rows['Post_pp'] . "' style='width:50px; height:50px;' />";?></a></td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<? echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<? echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <? // close while loop } // close connection mysql_close(); ?> <?=$pagination?> </td> </tr> </table>
-
Ok so at the minute I have designed a working forum. I am now trying to implement pagination into the threads. At the minute this is the working code before pagination. <br /> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM biggartfp9_forum_threadst ORDER BY Post_id DESC LIMIT 15 " ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <table class="acc_status_statuses"> <tr> <td class="acc_status_img" rowspan="2" valign="top"><a href="profile.php?username=<?php echo $rows['Post_username']; ?>"><?php echo "<img class='profile_pic' src='../Profile_thumbs/". $rows['Post_pp'] . "' style='width:50px; height:50px;' />";?></a></td> <td class="acc_alerts_posted"> In <a class="forum_cat" href="forum_filter.php?id=<? echo $rows['Post_type']; ?>"><?php echo $rows['Post_type']; ?></a> , by <a class="forum_cat" href="profile.php?username=<? echo $rows['Post_username']; ?>"><?php echo $rows['Post_username']; ?></a> on <?php echo $rows['Post_date']; ?> </td> </tr> <tr> <td class="acc_alerts_comment" valign="top"> <a class="forum_subject_link" href="forum_view.php?Post_id=<? echo $rows['Post_id']; ?>"><?php echo $rows['Post_subject']; ?></a> </td> </tr> </table> <br /> <?php // close while loop } // close connection mysql_close(); ?> </td> </tr> </table> And this is the pagination code i am trying to use. <br /> <table cellpadding="0" cellspacing="0" class="acc_status_table"> <tr> <td class="forum_lt">Latest Thread's</td> </tr> <tr> <td class="acc_status_feed"> <?php /* Place code to connect to your DB here. */ include('config.php'); // include your code to connect to DB. $tbl_name="biggartfp9_forum_threadst"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 3; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "forum_pagetest.php"; //your file name (the name of this file) $limit = 5; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>"; else $pagination.= "<span class=\"disabled\">« previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>"; else $pagination.= "<span class=\"disabled\">next »</span>"; $pagination.= "</div>\n"; } ?> <?php while($row = mysql_fetch_array($result)) { // close while loop } ?> <?=$pagination?> </td> </tr> </table> I am having trouble adding my old while loop intot he new pagination code, i know i have to add the table i want to echo, but then what syntax do i use to echo the rows of data?
-
Can anyone help?
-
so where would i move my header to? and also how do i register my sessions the new way? Sorry but I am just getting the hang of php so please bare with me.