Jump to content

cags

Staff Alumni
  • Posts

    3,217
  • Joined

  • Last visited

Everything posted by cags

  1. As MrAdam already said there are lots of ways of doing it. Basically what you are talking about is a CMS (content management system). The idea revolves around information being stored somewhere, generally in a database, and then included in the file, as and when required. An example of it at it's most basic. Imagine you have a database table like so. Database Table ==== id, page_name, page_link, page_content On your index page you could use something like... <?php if(isset($_GET['id'])) { // display requested page $sql = "SELECT * FROM `table` WHERE id=" . $_GET['id']; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo '<h1>' . $row['page_name'] . '</h1>'; echo '<p>' . $row['page_content'] . '</p>'; } else { // display list of pages $sql = "SELECT `id`, `page_link` FROM `table`"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo '<a href="index.php&page=' . $row['id'] . '" />' . $row['page_link'] . '</a>'; } } ?> Bare in mind that is a far from secure script, it doesn't check for errors or anything, but it will hopefully give you an idea of how it works. If it doesn't there are many, many tutorials available for coding CMS systems. I'm sure theres one here on PHPFreaks (I'm new so I don't know for sure), if not theres certainly one at PHPAcademy.info and at DevelopPHP.com
  2. Assuming I understand you, the code you have looks essentially correct bar one thing. You have <?php $_GET['download'] ?> which assumably means you want the value of $_GET['download'] to appear at that point in the HTML, that being the case you need to echo/ print it out. (also don't forget the semicolon) <form method="POST" action="check1.php?download=<?php echo $_GET['download']; ?>">
  3. Try using file_get_contents() instead of fopen().
  4. The final line of your code adds "&pagination=1" to your URL, and it will be ran every time. Since before that you also extract out all the old parameters from the original query string, this will obviously keep adding it every time you change page. One solution would be to only add "&pagination=1" if it's not already a parameter. Something like... <?php if(!in_array("pagination=1", $params)) { // add &pagination=1 } ?>
  5. If your function is defined like so... function search_field($startFrom, $recordperPage, $searchCat, $searchField) { // other code here } It is expecting you to pass those 4 variables in when you call the function like so... $results = search_field($startFrom, $recordperPage, $searchCat, $searchField);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.