New Coder Posted May 24, 2007 Share Posted May 24, 2007 Hello all, I have a site that will display reports that have been made against a product which are viewable one by one. I want people to make comments on the reports. I will try to explain. I want a page to load that will display the report that was first written about the product. At the bottom of the page I would like a free text area that the viewer can write their comments about the given report. I would then like them to be able to press next to display the second report that was made against the product along with the text area and what they have already written in comments from the previous report, so that they can add more comments about report 2 and so on and so on. Once they reach the last report I would like the next button to become view comments (maybe??) which will take them to a screen which will display their comments they have written about all the reports, edit if required and then save. So my questions are these. All products reports start with a review id = 1 because the product id is unique, but will have a different number of reports written about them. I can obviously get it to display the first report by setting the query variable to 1 but how do I get it to auto increment so that it will show the next report? This is where I’m guessing maybe an array?? But I have no real experience of theses. How do I get it to change what page the next button goes to once it cannot find any more reports for the product? Hope I have explained well enough. All help greatly received Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/52788-help-with-array-maybe/ Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 Can you show some code!.. Quote Link to comment https://forums.phpfreaks.com/topic/52788-help-with-array-maybe/#findComment-260614 Share on other sites More sharing options...
New Coder Posted May 24, 2007 Author Share Posted May 24, 2007 Ok this is what I've got so far. Work in progress so will be neater when finished. $row = mssql_fetch_array( $rs ) ; while($rowodbc = odbc_fetch_array($result)){ $author = rtrim($rowodbc["author"]); $list = "<h3><b>Review Number : </b>".$review_id."</h3>"; $list .= "<p><b>Review Title : </b>".$rowodbc["review_title"]."</p>"; $list .= "<p><b>Author : </b>$author</p>"; $list .= "<p><b>Date of Review : </b>".date("l, jS F Y", strtotime($rowodbc["review_dt"]))."</p>"; $list .= "<p style=\"margin-bottom:0\"><b>Product : </b>".$row["product"]." </p>"; mssql_free_result($rs); $list .= "<table border=\"0\" align= \"center\" cellpadding=\"2\" width=\"98%\">"; $list .= "<tr>"; $list .= "<th class=table colspan=\"4\"><br>Overview<br></th>"; $list .= "</tr><tr>"; $list .= "<td class=tblleft colspan=\"4\">".$rowodbc["prod_desc"]."</td>"; $list .= "</tr>"; $list .= "<tr><br>"; $list .= "<th class=table colspan=\"4\"><br>Issues<br><br></th>"; $list .= "</tr><tr>"; $list .= "<td class=tblleft colspan=\"4\">".$rowodbc["issues"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"4\"><br>Suggestions<br><br></th>"; $list .= "</tr><tr>"; $list .= "<td class=tblleft colspan=\"4\">".$rowodbc["suggestions"]."</td>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"2\">Ratings</th>"; $list .= "<td class=tblleft width=\"25%\">Average - ".$totperc."%"."</td>"; $list .= "<td class=tblleft width=\"25%\">Target - ".$rowodbc["perc_target"]."%</td>"; $list .= "</tr>"; $list .= "<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>"; $list .= "<tr>"; $list .= "<th class=table colspan=\"4\">Features</th>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th class=table width=\"25%\">Feature</th>"; $list .= "<th class=table width=\"25%\">Application</th>"; $list .= "<th class=table width=\"25%\">Rating</th>"; $list .= "<th class=table width=\"25%\">Included</th>"; $list .= "</tr>"; while ($row6 = mssql_fetch_array( $rs6 )) { $list .= "<tr>"; $list .= "<td class=table>".$row6["feature"]."</td>"; $list .= "<td class=table>".$row6["application"]."</td>"; $list .= "<td class=table>".$row6["rating"]."</td>"; $list .= "<td class=table>".$row6["inclusive"]."</td>"; $list .= "</tr>"; } $list .= "</table>"; #list details echo( $list ."</h4><br><h3>Summary</h3><br><h4>" .$rowodbc["summary"] ."</h4>"); } $list2 = "<b><p>Comments</p></b><br><center><textarea name=\"comments\" cols=\"60\" rows=\"6\"></textarea></center>"; echo ("<form action=\"\"> <hr>" .$list2 ." <br> <input type=\"submit\" value=\"Next\"></form>"); This only displays the first review because in the code I have $review_id = '1'; I'm not really sure where to start to get it to reload page on the press of next but to change review_id to 2 and so on. Plus to stop when it reaches no more records. Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/52788-help-with-array-maybe/#findComment-260630 Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 Basically you want pagination.. when you select from the database it should be something like.. SELECT * FROM table WHERE id = 1; your need to change this to SELECT * FROM table WHERE id = {$_GET['id']}; then you can add a link at the bottom which would be "h##p://domain.com/thepage.php?id=".($_GET['id']+1); thats the basics Quote Link to comment https://forums.phpfreaks.com/topic/52788-help-with-array-maybe/#findComment-260651 Share on other sites More sharing options...
New Coder Posted May 24, 2007 Author Share Posted May 24, 2007 Ok thanks. pagination is something that is new to me, but I will look into it. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/52788-help-with-array-maybe/#findComment-260725 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.