Jump to content

babydoll

Members
  • Posts

    4
  • Joined

  • Last visited

babydoll's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. babydoll

    pagination

    thanx,i will bear that in mind: any help with the pagination please?
  2. hii tried what u said removed the ' from the date vars and echoed the whole sql stmnt.which is select topics.topic_id, posts.topic_id, topic_title, mod_id, topic_creator, topic_role, post_timestamp from topics, posts where topics.topic_id=posts.topic_id , mod_id="COA122" and post_timestamp between 2006-08-07 and 2006-08-19 it doesnt give me any errors, however whn i removed the tablename.fieldx thing it showed part of the out put with some noticed of undefined vars but i need to logically get output from the tables.is there anywhere that i can get precise mysql sql syntax so that i try that please.
  3. babydoll

    pagination

    hithis my script for pagination it is working partly.am happy for that but, it only displays the 1st page, no links to the second pageso the remaining rows too are not displayed.here is the code, help anybody please include ('connection.php'); $limit = 10; // sets limit of how many results to show per page $query_count = "SELECT count(*) FROM topics"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); // a count of all the total rows in the table//Checks if the $page variable is empty (not set)// If it is empty, then we are on page 1 if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); // data start check ie for each page which row is to satr from //database query to select items for diaplay $query = "SELECT * FROM topics order by post_timestamp desc LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); // a msessage for when table is empty } //data display echo "<table border=\"1\" cellpadding=\"2\" align=\"centre\">"; echo "<tr><th>Article Starter</th>"; echo "<th>Article Content</th>"; echo "<th>Module</th>"; echo "<th> Last Post By </th>"; echo "<th>Role</th>"; echo "<th>Date</th>"; while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td><a href='reply_form2.php?topic=".$row['topic_title']."'>". $row['topic_title']."</a></td>"; echo "<td>". $row['topic_details']."</td>"; echo "<td>". $row['mod_id']."</td>"; echo "<td>". $row['topic_creator']."</td>"; echo "<td>".$row['role']."</td>"; echo "<td>" .$row['post_timestamp']."</td>"; echo "</tr>"; } echo "</table>"; //setting up the links on the page numbers if($page != 1){ $pageprev = $page--; echo("<a href=\"new_paging.php?page=$pageprev\"> PREV </a> "); } $numofpages = $totalrows / $limit; // We divide our total amount of rows (for example 102) by the limit (25). //This will yield items per page also number of pages, if we have extra rows remaining for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"new_paging.php?page=$i\">$i</a> "); } }// here handles the surplus rows if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); } else{ echo("<a href=\"new_paging.php?page=$i\">$i</a> "); } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"new_paging.php?page=$pagenext\"> NEXT </a>"); } } mysql_free_result($result); how does one paste php code in this forum because it makes it easier to read the code.thanks
  4. hi y'allam a newbie and am having crisis with my sql stmnt.the backend of my app is mysql and the sql statement i want to work is $sql =select topic_title, topics.mod_id, topic_creator, topics.role, topics.post_timestamp, post_creator, posts.role, posts.post_timestamp from topics, posts where topics.topic_ic=posts.topic_id, topics.mod_id=$mod , posts.post_timestamp between '$startdate and '$enddate am trying to generate a report from 2 tables. where the user will enter the search criteria and time frame given by $mod,$startdate and $enddate respectivelyPLEASE HELP
×
×
  • Create New...