nickbunyun Posted April 24, 2008 Share Posted April 24, 2008 ok so just to give you guys a feel of the infos i need to pull out from the db.. this is how much goes in.. $sql="INSERT INTO feedback (date, zipcode, groupadults, groupchildren, findout, findoutother, timesvisit, hoursofop, ryv_likelihood, ryv_info, ryv_helpfull, ryv_cleanliness, ryv_condition, ryv_appeal, ryv_value, comments, suggestionfuture, overall, primaryreason, programtitle, rtp_expect, rtp_interesting, rtp_length, rtp_amount, rtp_conveniece, rtp_value, rtp_ease, programcomments, likebest, attendagain, attendsug, suggestionfutureprograms, email, gehc_member) VALUES ('$dateinsert','$_POST[zipcode]','$_POST[groupadults]','$_POST[groupchildren]','$_POST[findout]','$_POST[findoutother]','$_POST[timesvisit]','$_POST[hoursofop]','$_POST[ryv_likelihood]','$_POST[ryv_info]','$_POST[ryv_helpfull]','$_POST[ryv_cleanliness]','$_POST[ryv_condition]','$_POST[ryv_appeal]','$_POST[ryv_value]','$_POST[comments]','$_POST[suggestionfuture]','$_POST[overall]','$_POST[primaryreason]','$_POST[programtitle]','$_POST[rtp_expect]','$_POST[rtp_interesting]','$_POST[rtp_length]','$_POST[rtp_amount]','$_POST[rtp_conveniece]','$_POST[rtp_value]','$_POST[rtp_ease]','$_POST[programcomments]','$_POST[likebest]','$_POST[attendagain]','$_POST[attendsug]','$_POST[suggestionfutureprograms]','$_POST[email]','$_POST[gehc_member]')"; now i also have to add the QUESTIONS to those.. to see which one goes where.. now im wodering.. how can i do it.. so it only shows 2-3.. maybe 4 per page... asc by date? Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted April 24, 2008 Share Posted April 24, 2008 SELECT * FROM table WHERE blah=blah LIMIT 3 ORDER BY date ASC Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 24, 2008 Author Share Posted April 24, 2008 can u put it a little more explained? im a noob... would i have to do it for all pages or how ? i still want all of em... but like... first 3 on page one 4-6 page two 6-9 page three etc.. thanks Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 25, 2008 Author Share Posted April 25, 2008 lil bump ? Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted April 25, 2008 Share Posted April 25, 2008 <?php $page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] >= 1 ? $_GET['page'] : 1; $per_page = 2;// set this $count_q = mysql_query("SELECT COUNT(id) FROM your table"); $count_r = mysql_fetch_row($count_q); $count = $count_r[0]; if($page > ceil($count/$per_page)) $page = 1; $limit_min = ($page-1)*$per_page; foreach($res as $x) $w[] = "blah = blah "; // change this $w = implode('OR', $w); mysql_select_db(" you databse ") or die(mysql_error());// change this $result = mysql_query("SELECT `title`,`type`,`game_picture_url` FROM `game` WHERE $w LIMIT {$limit_min}, {$per_page}")or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo info for each thing } ?> it would be something like you document.php?page=5 Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 25, 2008 Author Share Posted April 25, 2008 i think i get the main idea for it.. but what do i put here foreach($res as $x) $w[] = "blah = blah "; // change this i dont exactly know what blah = blah should be Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 25, 2008 Author Share Posted April 25, 2008 aanny1? Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 25, 2008 Share Posted April 25, 2008 foreach($res as $x) $w[] = "blah = blah "; // change this i dont exactly know what blah = blah should be first blah = the table field your are search by in the database. second blah = the criteria. So if your searching for all last names of dork `LastName` = 'dork' is the same as blah = blah (as stated) Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 25, 2008 Author Share Posted April 25, 2008 ya but i dont want only 2 fields.. i want ALL OF THEM.. but because theres about 32 fields.. i dont want them in ONE file.. i want them echoing 2-3 query rows on each page. Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 25, 2008 Share Posted April 25, 2008 So you want something like: page1.php //Display the first and last name page2.php //Display the department and phone number page3.php //Display the salary and start date OR something like page1.php //Display First Last Names, department, phone number, salary, and start date of the first 2 records in the database. page2.php //Display First Last Names, department, phone number, salary, and start date of the NEXT 2 records in the database. page3.php //Display First Last Names, department, phone number, salary, and start date of the NEXT 2 records in the database. Quote Link to comment Share on other sites More sharing options...
nickbunyun Posted April 26, 2008 Author Share Posted April 26, 2008 page1.php //Display First Last Names, department, phone number, salary, and start date of the first 2 records in the database. page2.php //Display First Last Names, department, phone number, salary, and start date of the NEXT 2 records in the database. page3.php //Display First Last Names, department, phone number, salary, and start date of the NEXT 2 records in the database. that... sorry if i didnt explain it correctly.. kinda hard when u dont know exactly what ur doing.. but yeah.. that Quote Link to comment Share on other sites More sharing options...
haku Posted April 26, 2008 Share Posted April 26, 2008 You need to use a technique called pagination. If you google it, you will find many tutorials on how to do it. Basically it involves first querying the database to see how many total records there are, then dividing that by 2 (since you want to show two queries on each page). That will tell you how many pages there are supposed to be. Then you create links to each page. You can see the technique in effect on this any any other forum - where it shows links to page 2, 3, 4 and so on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.