contra10
-
Posts
402 -
Joined
-
Last visited
Never
Posts posted by contra10
-
-
this script for some reason doesnt work
<script type="text/javascript"> <?php echo "var commentsbook={\n"; //Dynamically output javascript variable $commentids=mysql_query("SELECT * FROM post_profile WHERE userid = '$idp' ORDER BY ppid DESC") or die(mysql_error()); //get IDs to last 5 comment pages $idarray=array(); while ($theid=mysql_fetch_array($commentids)){ array_push($idarray, "'http://localhost/mypost/index.php?user='".$idp."'&id=" . $theid[id] . "'"); } echo "pages: [" . implode(",", $idarray) . "],\n"; //output: pages: echo "selectedpage: 0\n}"; ?> var comments=new ajaxpageclass.createBook(commentsbook, "bookdiv", ["paginate-top", "paginate-bottom"]) </script>
i get no mysql errors
-
this is my script...but can't load any pages
<script type="text/javascript"> <?php echo "var commentsbook={\n"; //Dynamically output javascript variable $commentids=mysql_query("SELECT * FROM post_profile WHERE userid = '$idp' ORDER BY ppid DESC") or die(mysql_error()); //get IDs to last 5 comment pages $idarray=array(); while ($theid=mysql_fetch_array($commentids)){ array_push($idarray, "'http://localhost/mypost/index.php?user='".$idp."'&id=" . $theid[id] . "'"); } echo "pages: [" . implode(",", $idarray) . "],\n"; //output: pages: echo "selectedpage: 0\n}"; ?> var comments=new ajaxpageclass.createBook(commentsbook, "bookdiv", ["paginate-top", "paginate-bottom"]) </script>
-
im trying to create a new way of pagination ...currently im using this code
<?php if(is_numeric($_GET['user'])){ $idp = $_GET['user']; $insert3= "SELECT * FROM post_profile WHERE userid = '$idp' ORDER BY ppid 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_profile WHERE userid = '$idp' 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 = '$idp' 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']}"; $userdate= "{$info['datepost']}"; 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 $userdate</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> "; } ?>
but there is a javascript code that divides the pages into divs
<div style="width: 400px;"> <div class="virtualpage hidepiece"> First Piece within Content " </div> <div class="virtualpage hidepiece"> Second Piece within Content " </div> <div class="virtualpage hidepiece"> Third Piece within Content " </div> </div>
<div id="paginatediv" class="paginationstyle"> <a href="#" rel="previous" style="margin-right: 100px">Prev</a> <a href="#" rel="next">Next</a> </div>
and
<script type="text/javascript"> var pagecontent=new virtualpaginate({ piececlass: "virtualpage", //class of container for each piece of content piececontainer: "div", //container element type (ie: "div", "p" etc) pieces_per_page: 1, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc) defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting. persist: false //Remember last viewed page and recall it when user returns within a browser session? }) pagecontent.buildpagination(["paginatediv"]) </script>
to vaguely put it...how can i incorporate my code into this new way of pagination...I'm doing this so that i don't have to reload the page when a page number is clicked
sry for length
-
im trying to create a new way of pagination ...currently im using this code
<?php if(is_numeric($_GET['user'])){ $idp = $_GET['user']; $insert3= "SELECT * FROM post_profile WHERE userid = '$idp' ORDER BY ppid 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_profile WHERE userid = '$idp' 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 = '$idp' 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']}"; $userdate= "{$info['datepost']}"; 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 $userdate</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> "; } ?>
but there is a javascript code that divides the pages into divs
<div style="width: 400px;"> <div class="virtualpage hidepiece"> First Piece within Content " </div> <div class="virtualpage hidepiece"> Second Piece within Content " </div> <div class="virtualpage hidepiece"> Third Piece within Content " </div> </div>
<div id="paginatediv" class="paginationstyle"> <a href="#" rel="previous" style="margin-right: 100px">Prev</a> <a href="#" rel="next">Next</a> </div>
and
<script type="text/javascript"> var pagecontent=new virtualpaginate({ piececlass: "virtualpage", //class of container for each piece of content piececontainer: "div", //container element type (ie: "div", "p" etc) pieces_per_page: 1, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc) defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting. persist: false //Remember last viewed page and recall it when user returns within a browser session? }) pagecontent.buildpagination(["paginatediv"]) </script>
to vaguely put it...how can i incorporate my code into this new way of pagination...I'm doing this so that i don't have to reload the page when a page number is clicked
THIS MAY BE AN AJAX ISSUE
sry for length
-
-
i'm using this to get the average of a rating but it only calculates the lates input divided by the number of rows...
<?php $query="SELECT * FROM `ratings` WHERE `ratedid`= '$id'"; $nt=mysql_query($query); echo mysql_error(); $countofrate= mysql_num_rows($nt); while($row=mysql_fetch_array($nt)){ $rateresults = "{$row['rate']}"; } $average = $rateresults / $countofrate; print("Rated: $average"); ?>
i don't know if COUNT is supposed to be used or if there is a way to add up all the rows...
-
this echos the same number
<?php $query="select * from groups where $q "; $query2 ="select * from groups where $q "; } // end of if else based on type value $nt=mysql_query($query); echo mysql_error(); $members = mysql_num_rows($nt); while($row=mysql_fetch_array($nt)){ $eid = "{$row['id']}"; echo "<tr><td valign='top' width='60' height='40'><img src='http://localhost/groupsio/imagereplace.php?id=$eid'></td>"; echo "<td valign='top'><a style='text-decoration:none' href='http://localhost/groupsio/index.php?grp=$eid'>$row[name]</a><br>"; echo "$members Members</td></tr>"; } ?>
-
could i somehow run a query in a while statement?
<?php while($row=mysql_fetch_array($nt)){ $eid = "{$row['id']}"; $qor= mysql_query("select * from groups where id='$eid'"); $ntacc=mysql_query($qor); $members = mysql_num_rows($ntacc); echo "<tr><td valign='top' width='60' height='10'><img src='http://localhost/groupsio/imagereplace.php?id=$eid'></td>"; echo "<td valign='top'><a style='text-decoration:none' href='http://localhost/groupsio/index.php?grp=$eid'>$row[name]</a><br>"; echo "$members Members</td></tr>"; ?>
i'm trying to catch the eid
-
with or it echos just one number in this case "2" i guess its echoing the number of groups this user is in
-
$q suppose to break down the group name from mysql...suppose to be a keyword search...it works...but when i put "name='$q'"; it doesn't work
-
I'm trying to echo the amount of members in a group in a search but i keep getting 0
<?php if($type<>"any"){ mysql_query("select * from groups where name='$search_text'"); }else{ $kt=split(" ",$search_text);//Breaking the string to array of words // Now let us generate the sql while(list($key,$val)=each($kt)){ if($val<>" " and strlen($val) > 0){$q .= " name like '%$val%' or ";} }// end of while $q=substr($q,0,(strLen($q)-3)); // this will remove the last or from the string. $query="select * from groups where $q "; $queryacc="select * from groups where name='$search_text' and $q"; } // end of if else based on type value $nt=mysql_query($query); $ntacc=mysql_query($queryacc); echo mysql_error(); $members = mysql_num_rows($ntacc); while($row=mysql_fetch_array($nt)){ $eid = "{$row['id']}"; echo "<tr><td valign='top' width='60' height='10'><img src='http://localhost/groupsio/imagereplace.php?id=$eid'></td>"; echo "<td valign='top'><a style='text-decoration:none' href='http://localhost/groupsio/index.php?grp=$eid'>$row[name]</a><br>"; echo "$members Members</td></tr>"; } ?>
-
do all the checking in the php script and when all is finished place at the bottom of your script inside if brackets...im assuming **if (isset($_POST['send'])){ }**
// Create the URL string $url = "http://localhost/..."; // Finall Echo the meta tag echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">');
that should redirect after you have completed all the checking u wish...this is a backup to using header...not really used toomuch since its html in php but it works
-
im trying to search mysql in a way that is ordered by one of my rows...the first part of the code works well but if i isset another area and do the same orderinging i get a msqlfetch error
<?php $query = "SELECT * FROM `events` WHERE `country`='$postcountry' and `continent`='$postcontinent' and `state_province` = '$poststate' and `val`= 'true' and `evcategory`='$posteva' ORDER BY dateofevsearch ASC"; if(isset($_POST['submit']) and ($_POST['continent']) and ($_POST['country']) and ($_POST['state']) and ($_POST['eva']) and ($_POST['event']) and ($_POST['city'])){$query .= "and `evcity` = '$postcity' ORDER BY dateofevsearch ASC";} ?> ['code]
-
illl use magin: 0
-
that worked thanks
-
for some reason it didn't work
<?php $text = ($evdescription); $newtext = wordwrap($text, 20, "<br />\n"); echo "<table border='1' align='right' width='600'>"; echo "<tr><td width='80%' valign='top' align='center'><FONT FACE='ariel' size'12'><h1><b>$evname</b></fOnt></td></tr>"; echo "<tr><td height='200' valign='top' align='left' width='300px'>$newtext</td></tr>"; ?>
-
i have in my table an echoed value that can be really long...thing is how do i limit the amount of words in a row. At the moment it is just echoed throughtout the table and forces the table to become longer
<?php echo "<table border='1' align='right' width='600'>"; echo "<tr><td width='80%' valign='top' align='center'><FONT FACE='ariel' size'12'><h1><b>$evname</b></fOnt></td></tr>"; echo "<tr><td height='200' valign='top' align='left' width='300px'>$evdescription</td></tr>"; ?>
-
thank you
-
still working on the javascript...but the 30px...didn;t word for me....regardless as to wheter i put it in the td or table tags
-
i'm trying to limit the amount of characters entered in text area
but it won't limit
<textarea name="description" type="description" cols="50" rows="7" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea>
at the same time...i also want to show the information that is entered into mysql using php...it shows but in a straight line...how can i use html to limit the amunt of words in a row
<?php echo "<tr><td height='200' valign='top' align='left'>$evdescription</td></tr>"; ?>
-
another dumb mistake...i should have echoed the check before i ran the submit...like this
<?php if(is_numeric($_GET['ev'])){ $id = $_GET['ev']; } // checks if the username is in use for event $check = mysql_query("SELECT * FROM `events_subscribers` WHERE `eventid` = '$id' AND `username`='$username'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the username for event exists it gives an error if ($check2 > 0) { die('<FONT FACE=ariel size=6><b>You are attending this event</b></FONT>'); } if (isset($_POST['submit'])){ ?>
thnks 4 the help
-
no the username is recieved from cookie file, which is echoed in header.php
ill input itto the code though to make it easier
<?php if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; } if(is_numeric($_GET['ev'])){ $id = $_GET['ev']; } ... ?>
-
ok i see where i went wrong...but how should i fix this...i noticed the form is outsidde of the php tags...(duh to mysself)
<?php if(is_numeric($_GET['ev'])){ $id = $_GET['ev']; } if (isset($_POST['submit'])){ // checks if the username is in use for event $check = mysql_query("SELECT * FROM `events_subscribers` WHERE `eventid` = '$id' AND `username`='$username'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the username for event exists it gives an error if ($check2 > 0) { die('<FONT FACE=ariel size=6><b>You are attending this event</b></FONT>'); } else{ $query= "SELECT * FROM `events` WHERE `eid` = '$id'"; $result = mysql_query($query) or die(mysql_error());; $event = mysql_fetch_assoc($result); $eventname = "{$event['evname']}"; $eventid = "{$event['eid']}"; $query2= "SELECT `id` FROM `users` WHERE `username` = '$username'"; $result2 = mysql_query($query2) or die(mysql_error());; $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $insert = "INSERT INTO `events_subscribers` (userid, username, eventid, eventname) VALUES ('$userid', '$username', '$eventid', '$eventname')"; $add_subscription = mysql_query($insert) or die(mysql_error()); // Create the URL string $url = "http://localhost/events/eventview.php?ev=$id"; // Finall Echo the meta tag echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">'); } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type='submit' name='submit' value='Attend Event'></td> <input type='hidden' name='ev' value='<?php echo $_GET['ev']; ?>'> </form>
-
hi i want a button to not display if the useralready exists for an event
my coding is
<?php if(is_numeric($_GET['ev'])){ $id = $_GET['ev']; } if (isset($_POST['submit'])){ // checks if the username is in use for event $check = mysql_query("SELECT * FROM `events_subscribers` WHERE `eventid` = '$id' AND `username`='$username'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the username for event exists it gives an error if ($check2 > 1) { die('<FONT FACE=ariel size=6><b>You are attending this event</b></FONT>'); } ?> followed by an else statement for the button the button keeps showing even if a person has already joined...i checked my query all elements are in it and all names are correct
can't get pagination
in PHP Coding Help
Posted
its suppose to show the posts that a user left...I'm trying to make the pagination dynamic so that a page doesn't reload when clicking onto anothe page
i uused this before as pagination