contra10
-
Posts
402 -
Joined
-
Last visited
Never
Posts posted by contra10
-
-
ok thaks for the tip
-
i still get those errors, maybe i should do photo upload differently?
-
i get
Notice: Undefined index: action in C:\wamp\www\photoupload\index.php on line 12 Notice: Undefined variable: error in C:\wamp\www\photoupload\index.php on line 49
-
i can't seem to wrap my head around this, maybe im attempting to do this the wrong way but im creating a user specific upload for profile, and here part of my code
<?php //print_r($_POST); if($_POST["action"] == "Upload Image") { unset($imagename); if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES; if(!isset($_FILES['image_file'])) $error["image_file"] = "An image was not found."; $imagename = basename($_FILES['image_file']['name']); //echo $imagename; if(empty($imagename)) $error["imagename"] = "The name of the image was not found."; if(empty($error)) { $newimage = "file:///C|/wamp/www/images/" . $imagename; //echo $newimage; $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage); if(empty($result)) $error["result"] = "There was an error moving the uploaded file."; } } ?> <form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?php $_SERVER["PHP_SELF"];?>"> <p><input type="file" name="image_file" size="20"></p> <p><input type="submit" value="Upload Image" name="action"></p> </form> <?php if(is_array($error)) { while(list($key, $val) = each($error)) { echo $val; echo "<br>\n"; } } ?>
i placed my file images in *www* folder and nothing is going there at the same time how do i make the photo user specific, i passed on the user id to this upload page
-
i can echo all the variable im guessing i should do a hidden value for the other stuff but wat about the updating
-
is there something wrong with the syntax?
-
im trying to input some variables and only afew are entering and i can't seem to update a value
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['request'])){ $id = $_GET['request']; $friend= "SELECT * FROM users WHERE id = '$id'"; $friendget = mysql_query($friend) or die(mysql_error()); while ($friendrequest = mysql_fetch_assoc($friendget)) { $usernamef = "{$friendrequest['username']}"; $usernamefid = "{$friendrequest['userid']}"; $usersex = "{$friendrequest['sex']}"; $usercity = "{$friendrequest['city']}"; $usercountry = "{$friendrequest['country']}"; $userfrid = "{$friendrequest['frid']}"; echo "<table border ='1' align='center'>"; echo "<tr>"; echo "<td width='400' height='300'>$usernamef</td>"; echo "</tr>"; echo "<tr>"; echo "<td>$usersex, $usercity, $usercountry</td>"; echo "</tr>"; } echo "</table>"; } if (isset($_POST['add'])) { $query = "SELECT * FROM users WHERE username = '$username'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $userid = "{$row['id']}"; $friendaccept= 2; $query2= "UPDATE friend_request SET value = '$friendaccept' WHERE username = '$usernamef' AND requestname = '$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $insert = "INSERT INTO friends (userid, username, friendid, friendname) VALUES ('$userid', '$username', '$usernamefid', '$usernamef')"; $add_group = mysql_query($insert) or die(mysql_error()); ?>
i can't update the value to 2 and for some reason only part of variables are entering the table, userid and username are entering while usernamefid and usernamef won't enter
-
where exaclty should i set up the array? and what should i input?
-
something like this
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); $requestint = 1; $data = ("SELECT * FROM friend_request WHERE requestname = '$username' AND value = '$requestint' ORDER BY frid DESC") or die(mysql_error()); $postrequest = mysql_query($data); while($info = mysql_fetch_array($postrequest)) { $userrequesting= "{$info['username']}"; echo "$userrequesting wants to be your friend <input type='submit' name='add' value='Add Friend'> <input type='submit' name='reject' value='Reject Friend'></a><br>"; } ?> </table> </form>
?
-
maybe im attempting this the wrong way but i want to put a form in the brackets as im attempting to have an add friend, reject friend. If i put the form seperate then it will only say add friend and reject friend once instead for each person who adds the user
my code is
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); $requestint = 1; $data = ("SELECT * FROM friend_request WHERE requestname = '$username' AND value = '$requestint' ORDER BY frid DESC") or die(mysql_error()); $postrequest = mysql_query($data); while($info = mysql_fetch_array($postrequest)) { $userrequesting= "{$info['username']}"; echo "$userrequesting wants to be your friend <input type='submit' name='add' value='Add Friend'> <input type='submit' name='reject' value='Reject Friend'></a><br>"; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="right"><input type="submit" name="add" value="Add Friend"></td> <td align="right"><input type="submit" name="reject" value="Reject Friend"></td></tr> </table> </form>
the form in the php brackets or the buttons of the form are the way that i want my request to look like, but i need to do an action and i can't put $_SERVER['PHP_SELF']; tell me if im making any sense
-
i can echo the $id, im not sure what to do
-
i'm trying to get information to echo from a db query for some reason its not working
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $post3= "SELECT * FROM post_profile WHERE userid = '$id' ORDER BY ppid DESC"; $postq = mysql_query($post3) or die(mysql_error()); } //This checks to see if there is a page number. If not, it will set it to page 1 if (!isset($pagenum)) { $pagenum = (isset($_GET['pagenum'])) ? $_GET['pagenum'] : 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM post_profile WHERE userid = '$id' ORDER BY ppid DESC") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = "SELECT * FROM post_profile WHERE userid = '$id' ORDER BY ppid DESC LIMIT 10"; $posts = mysql_query($data_p) or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array($posts)) { $userpost= "{$info['post']}"; $usernamep= "{$info['postingusername']}"; $usermonth= "{$info['month']}"; $userday= "{$info['day']}"; $useryear= "{$info['year']}"; $userhour= "{$info['hour']}"; $userminutes = "{$info['minute']}"; $usermeridiem = "{$info['meridiem']}"; echo "<table border='0' align='center'>"; echo "<tr>"; echo"<td width= '500' align='center' bgcolor='black'><FONT FACE='ariel' SIZE='2' color='#0094f7'> $userpost</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='right'><FONT FACE='ariel' SIZE='2' color='#0094f7'>Posted by $usernamep on $usermonth, $userday $useryear at $userhour:$userminutes $usermeridiem</td>"; echo "<tr>"; echo"</table>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='http://localhost/mypost/index.php?user=$id&pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='http://localhost/mypost/index.php?user=$id&pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='http://localhost/mypost/index.php?user=$id&pagenum=$next'>Next -></a> "; echo " "; echo " <a href='http://localhost/mypost/index.php?user=$id&pagenum=$last'>Last ->></a> "; } ?>
HAPPY NEW YEAR!
-
hey its actuallaty the date
//This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; $hour = date('g', $date) ; $minutes = date('i', $date) ; $meridiem = date('a', $date) ;
for some reason when i put the minutes in my sql and echo it out i get on of the digits, not the leading zeros for the minutes lik instead of 9:08 i get 9:8
-
btw i tried to redirect with only the form and i tried it with only the header neither worked :'(
-
i tried the
<form action=""index.php?user=<?php echo $id; ?>" method="post">
but it didn't work i even tried to from it into this
<form action="index.php?user=<?php echo ($id); ?>" method="post">
still didn't work...
i guess i can change the header location if i user it in the php code but when i place it at the top near the isset post then i still don't get anywhere
-
hi my header keeps directing me to
http://localhost/profile/index.php
when it should be
http://localhost/profile/index.php?user=$id
after post is clicked
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['user'])){ $id = $_GET['user']; $postuser= "SELECT * FROM users WHERE id = '$id'"; $post = mysql_query($postuser) or die(mysql_error()); while ($posted = mysql_fetch_assoc($post)) { $usernamep = "{$posted['name']}"; } } if(isset($_COOKIE['ID_my_site'])) { $usernameq = $_COOKIE['ID_my_site']; $inpost = mysql_query("SELECT * FROM users WHERE username ='$usernameq'") or die (mysql_error()); while($rowpost = mysql_fetch_assoc($inpost)) { $userposting = "{$rowpost['username']}"; $userpostingid = "{$rowpost['id']}"; } } //This code runs if the form has been submitted if (isset($_POST['post'])) { //This makes sure they did not leave any fields blank if (!$_POST['userpost']){ die('You did not complete all of the required fields'); } $query2= "SELECT id FROM users WHERE username = '$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $userpost = mysql_real_escape_string($_POST['userpost']); $postnamea = mysql_real_escape_string($_POST['profilename']); $ida = mysql_real_escape_string($_POST['profileid']); //This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; header("Location: http://localhost/profile/index.php?user=$id"); // now we insert it into the database $insert = "INSERT INTO post_profile (userid, username, postinguserid, postingusername, post, month, day, year) VALUES ('$id', '$username', '$userpostingid', '$usernameq', '$userpost', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error()); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } ?> <?php echo ($id);?> <?php echo($username);?> <?php echo($usernameq);?> <?php echo($userpostingid);?>
-
its funny how in programming there is no room for a simple mistake...
Thank you for pointing out the obvious
-
hi i can link to another page within the pagination but i need to get the id of group in order to continue to echo the results heres my code
<?php if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert3= "SELECT * FROM post_grp WHERE grpid = '$id' ORDER BY pgid DESC"; $topic3 = mysql_query($insert3) or die(mysql_error()); } //This checks to see if there is a page number. If not, it will set it to page 1 if (!isset($pagenum)) { $pagenum = (isset($_GET['pagenum'])) ? $_GET['pagenum'] : 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM post_grp WHERE grpid = '$id' ORDER BY pgid DESC") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = "SELECT * FROM post_grp WHERE grpname = '$grpname' ORDER BY pgid DESC $max"; $posts = mysql_query($data_p) or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array($posts)) { $userpost= "{$info['grppost']}"; $username= "{$info['username']}"; $usermonth= "{$info['month']}"; $userday= "{$info['day']}"; $useryear= "{$info['year']}"; echo "<table border='1' align='center'>"; echo "<tr>"; echo"<td width= '500' align='center'> $userpost</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='right'>Posted by $username on $usermonth, $userday $useryear</td>"; echo "<tr>"; echo"</table>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$last'>Last ->></a> "; } ?>
i need the results to continue on a different page with the id still attached in the url
-
i get no errors with this code, but i keep getting directed to
http://localhost/groupsio/post.php
where it echos all the post from every group not specific to this group
-
updated
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert1= "SELECT * FROM groups WHERE id = '$id'"; $topic1 = mysql_query($insert1) or die(mysql_error()); while ($topica = mysql_fetch_assoc($topic1)) { $grpname= "{$topica['name']}"; } } //This code runs if the form has been submitted if (isset($_POST['post'])) { //This makes sure they did not leave any fields blank if (!$_POST['userpost']){ die('You did not complete all of the required fields'); } $query2= "SELECT id FROM users WHERE username = '$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $userpost = mysql_real_escape_string($_POST['userpost']); $grpnamea = mysql_real_escape_string($_POST['grpname']); $ida = mysql_real_escape_string($_POST['grpid']); //This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; // now we insert it into the database $insert = "INSERT INTO post_grp (grpid, grpname, userid, username, grppost, month, day, year) VALUES ('$ida', '$grpnamea', '$userid', '$username', '$userpost', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error()); ?> <?php echo($grpname);?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="800" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> <tr><td><?php echo "<input type='hidden' name='grpname' value='$grpname'>";?></tr></td> <tr><td><?php echo "<input type='hidden' name='grpid' value='$id'>";?></td> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="800" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> <tr><td><?php echo "<input type='hidden' name='grpname' value='$grpname'>";?></tr></td> <tr><td><?php echo "<input type='hidden' name='grpid' value='$id'>";?></td> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } ?> <?php if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert3= "SELECT * FROM post_grp WHERE grpid = '$ida' ORDER BY pgid DESC"; $topic3 = mysql_query($insert3) or die(mysql_error()); } //This checks to see if there is a page number. If not, it will set it to page 1 if (!isset($pagenum)) { $pagenum = (isset($_GET['pagenum'])) ? $_GET['pagenum'] : 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM post_grp WHERE grpid = '$ida' ORDER BY pgid DESC") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = "SELECT * FROM post_grp WHERE grpname = '$grpname' ORDER BY pgid DESC $max"; $posts = mysql_query($data_p) or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array($posts)) { $userpost= "{$info['grppost']}"; $username= "{$info['username']}"; $usermonth= "{$info['month']}"; $userday= "{$info['day']}"; $useryear= "{$info['year']}"; echo "<table border='1' align='center'>"; echo "<tr>"; echo"<td width= '500' align='center'> $userpost</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='right'>Posted by $username on $usermonth, $userday $useryear</td>"; echo "<tr>"; echo"</table>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='http://localhost/groupsio/post.php?id=$id?pagenum=$last'>Last ->></a> "; } ?>
-
i guess i should, but the server was workking fine until i entered that code, everything else connect on my other pages and all runs smoothly
-
yes its runing, but that code isn't working. is there any other way?
-
my wamp server is running, when i change the code back to the first one stated it runs, but when i change it i get
mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10048)
even after i restart the connection
-
i thought this would work but apparently i get a connection error
<?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert1= "SELECT * FROM groups WHERE id = '$id'"; $topic1 = mysql_query($insert1) or die(mysql_error()); while ($topica = mysql_fetch_assoc($topic1)) { $grpname= "{$topica['name']}"; } } ?> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert1= "SELECT * FROM groups WHERE id = '$id'"; $topic1 = mysql_query($insert1) or die(mysql_error()); while ($topica = mysql_fetch_assoc($topic1)) { $grpname= "{$topica['name']}"; } } //This code runs if the form has been submitted if (isset($_POST['post'])) { //This makes sure they did not leave any fields blank if (!$_POST['userpost']){ die('You did not complete all of the required fields'); } $query2= "SELECT id FROM users WHERE username = '$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $userpost = mysql_real_escape_string($_POST['userpost']); $grpnamea = mysql_real_escape_string($_POST['grpname']); $ida = mysql_real_escape_string($_POST['grpid']); //This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; // now we insert it into the database $insert = "INSERT INTO post_grp (grpid, grpname, userid, username, grppost, month, day, year) VALUES ('$ida', '$grpnamea', '$userid', '$username', '$userpost', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error()); ?> <?php echo($grpname);?> <form action=<?php header ( "Location: http://localhost/groupsio/post.php?id=$ida" ) ;?> method="post"> <table border="0" width="800" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> <tr><td><?php echo "<input type='hidden' name='grpname' value='$grpname'>";?></tr></td> <tr><td><?php echo "<input type='hidden' name='grpid' value='$id'>";?></td> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } else { ?> <form action=<?php header ( "Location: http://localhost/groupsio/post.php?id=$ida" ) ;?> method="post"> <table border="0" width="800" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> <tr><td><?php echo "<input type='hidden' name='grpname' value='$grpname'>";?></tr></td> <tr><td><?php echo "<input type='hidden' name='grpid' value='$id'>";?></td> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } ?> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert3= "SELECT * FROM post_grp WHERE grpid = '$ida' ORDER BY pgid DESC"; $topic3 = mysql_query($insert3) or die(mysql_error()); } //This checks to see if there is a page number. If not, it will set it to page 1 if (!isset($pagenum)) { $pagenum = (isset($_GET['pagenum'])) ? $_GET['pagenum'] : 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM post_grp WHERE grpid = '$ida' ORDER BY pgid DESC") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = "SELECT * FROM post_grp WHERE grpname = '$grpname' ORDER BY pgid DESC $max"; $posts = mysql_query($data_p) or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array($posts)) { $userpost= "{$info['grppost']}"; $username= "{$info['username']}"; $usermonth= "{$info['month']}"; $userday= "{$info['day']}"; $useryear= "{$info['year']}"; echo "<table border='1' align='center'>"; echo "<tr>"; echo"<td width= '500' align='center'> $userpost</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='right'>Posted by $username on $usermonth, $userday $useryear</td>"; echo "<tr>"; echo"</table>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href= 'http://localhost/groupsio/post.php?id=$ida?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='http://localhost/groupsio/post.php?id=$ida?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='http://localhost/groupsio/post.php?id=$ida?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='http://localhost/groupsio/post.php?id=$ida?pagenum=$last'>Last ->></a> "; } ?>
[SOLVED] dealing with forward slashes
in PHP Coding Help
Posted
hi i want to know if i can find away around the fprward slahses they keep highlighting to green