PHP - Dynamic Page Help!
hey guys how you all doing? ok im really looking for some help i've been playing with this code for quite some time now and still not got the hang of it. i'm currently trying to code a dynamic website as a portfolio for my designs and im trying to get to view the news.php file with an 'id' to view in the index file using an include() but for some reason its not happening very well.
i keep getting the error message: Warning: include(inc/news.php?id=) [function.include]: failed to open stream: No error in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 Warning: include() [function.include]: Failed opening 'inc/news.php?id=' for inclusion (include_path='.;C:\xampplite\php\PEAR') in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 just wondering if anyone could shed any light on what i may have done wrong thanks guys ive left part of the code below if this will help. Code: [Select] <?php $page = $_GET['page']; $news = $_GET['id']; if(!$page){ getnews(); } else { if($page = news){ include("inc/news.php?id=".$news); } else include("inc/".$page.".php"); } ?> Similar Tutorialshey guys stuck on this one cant see why it wont work, hope someone can help. im trying to just change the content not the whole page while still only a admin can see it. if you get my jist. but everytime i click the link nothing shows up for some reason. thanks in advance. Code: [Select] <?php session_start(); include("login.php"); ?> <html> <body> <?php if(isset($_SESSION['user'])){ ?> <table width='90%' height='100%' border='1' align='center'> <tr valign='top'> <td><table width='60%' border='0' align='center'> <tr> <td colspan='3' align='center'>You've succesfully logged in.<p></td> </tr> <tr> <td><a href='index.php?page=post.php'>post news</a></td> <td><a href='index.php?page=mail.php'>mailing list</a></td> <td><a href='index.php?page=stats.php'>site stats</a></td> <td><a href='login.php?logout'>logout</a></p></td> </tr> <tr> <td colspan='3'> <?php $page = $_GET['page']; if($page){ include("inc/".$page.".php"); } ?> </td> </tr> </table></td> </tr> </table> ?> <?php } else { die(); } ?> </body> </html> Hey, I'm trying to make a dynamic php website. So far it's been working fine. All my pages are in a page folder and with my code I'm able to access it via "index.php?page=nameofphpfile" etc. Now I added a page under there with a similar code to the index and it is conflicting. This is the code for the index.php $page=$_GET['page']; if ($page) { include("pages/".$page.".php"); } else { echo "This Page Does Not Exist."; } } On my skin.php page when I try to put a GET variable in, I get the word THIS PAGE DOES NOT EXIST. I'm really stuck and need help, I know it's brief so please help me out here! -Francis I have written the following php statement and it works to show pages titles if I have an id in the url example. www.mysite.com/index.php?id=3 then the right page title is displayed but if I am on my home page www.mysite.com with no id the page title isn't displayed. I am running the code in the header in the title brackets. here is the code. The last else doesn't display my home page title any help would be great thank you very much... <title> <? if (isset($_GET['id'])) if($_GET['id'] == '1') { echo "LBT Services Page"; } else if($_GET['id'] == '2') { echo "About LBT"; } else if($_GET['id'] == '3') { echo "Contact LBT"; } else if($_GET['id'] == '4') { echo "Your Message to LBT has been Submitted"; } else if($_GET['id'] == '5') { echo "LBT Links Page"; } else if($_GET['id'] == '6') { echo "LBT Back-UP Plans"; } else { echo "LBT Home page"; } ?></title> Does anyone know how I would display a dynamic page title to my content pages? I currently have my index.php displaying the title for my page, but the content that i am displaying dynamicly also uses this title, want these pages to have their own titles.. Thanks Hi Guys, I'm pulling a html page from a database (html newsletter). In the code I have links that will open a lightbox and allow the user to add news articles into it via ajax. So the html is being updated without being send back to the browser. I have a "save" button which when the user clicks, I want to grab all of the html of the page and save it to the database. Not quite sure how to do this as the html that is being saved, is updated since it was retrieved by the browser. Hi everybody I am a PHP rookie for now, and I want to reload the same dynamic page - it's content in several languages - by clicking little flags which are located at some point on the page - AND ITS NOT WORKING. Clicking on the flag triggers a PHP script which basically says Code: [Select] ]$_SESSION['lang'] = <Some_language>; require ('webpage.php'); where webpage.php is the dynamic page, in different languages, with it's content drawn out from a database (which contains the content in all languages I chose to display, blah, blah) Funny thing - when I look at the page html (View Page Source) - it seems OK (identical from one page to the next) ! But WHAT is displayed after the first attempt to change the language is not. Is something fundamentally wrong with my approach ? Mike Hi, I wanted to make a dynamic php page. I want the user to choose an option you could select in an option box (html) and after that I wish that down the page some text would change. If I take option 1 -> text 1, option 2 -> text 2, ... But this doesn't work, do I need a button or something to made my code running, and how do I have to use it on the same page? Or is it possible to run it automaticly after a new choice? Thanx, Kevin My code: <?php /* Template Name: template voor Ieder1Trainer # */ get_header(); $Tacktiek = ""; $Tacktiek1 = "3-5-2"; $Tacktiek2 = "3-4-3"; $Tacktiek3 = "4-5-1"; $Tacktiek4 = "4-4-2"; $Tacktiek5 = "4-3-3"; $Tacktiek6 = "5-4-1"; $Tacktiek7 = "5-3-2"; $aantalDef; $aantalMid; $aantalAtt; ?> <div id="newsfeed"> <div class="banderol"> <div class="banderol_left"></div> <h1>Dynamic page</h1> </div> <?php if(is_user_logged_in()) { get_currentuserinfo(); //echo 'Username: ' . $current_user->user_login . "\n"; //echo 'User email: ' . $current_user->user_email . "\n"; ?> <!-- Here you choose a tactiek; 1,2,3, .. after that has been choosen I whise the next php-code would be run (the if-then-elseif-...) --> <tr> <td><p class="formulier">Kies je Tacktiek:</p></td> <td> <select size="1" name="$Tacktiek"> <option selected><?php echo $Tacktiek1;?></option> <option><?php echo $Tacktiek2;?></option> <option><?php echo $Tacktiek3;?></option> <option><?php echo $Tacktiek4;?></option> <option><?php echo $Tacktiek5;?></option> <option><?php echo $Tacktiek6;?></option> <option><?php echo $Tacktiek7;?></option> </select> </td> </tr> <!-- This must be run after choosen a tactiek. --> <?php if($Tacktiek == '3-5-2') { $aantalDef = 3; $aantalMid = 5; $aantalAtt = 2; } elseif($Tacktiek == '3-4-3') { $aantalDef = 3; $aantalMid = 4; $aantalAtt = 3; } elseif($Tacktiek == '4-5-1') { $aantalDef = 4; $aantalMid = 5; $aantalAtt = 1; } elseif($Tacktiek == '4-4-2') { $aantalDef = 4; $aantalMid = 4; $aantalAtt = 2; } elseif($Tacktiek == '4-3-3') { $aantalDef = 4; $aantalMid = 3; $aantalAtt = 3; } elseif($Tacktiek == '5-4-1') { $aantalDef = 5; $aantalMid = 4; $aantalAtt = 1; } elseif($Tacktiek == '5-3-2') { $aantalDef = 5; $aantalMid = 3; $aantalAtt = 2; } ?> <!-- After this run, the next code must be run and made a choose of text --> <tr> <td><p class="formulier"> <?php if($aantalDef == '3') { echo "3 defs"; //Choosen text if aantalDef == 3 } elseif($aantalDef == '4') { echo "4 defs"; //Choosen text if aantalDef == 4 } elseif($aantalDef == '5') { echo "5 defs"; //Choosen text if aantalDef == 5 } ?> </p></td> <!-- Other choose of options, but always the same options. --> <td> <select size="1" name="$Speler4"> <option selected><?php echo $NaamDef1;?></option> <option><?php echo $NaamDef2;?></option> <option><?php echo $NaamDefMid1;?></option> <option><?php echo $NaamDefMid2;?></option> <option><?php echo $NaamDefMid3;?></option> <option><?php echo $NaamDefMid4;?></option> <option><?php echo $NaamDefMid5;?></option> <option><?php echo $NaamDefMid6;?></option> <option><?php echo $NaamDefMid7;?></option> <option><?php echo $NaamDefMid8;?></option> <option><?php echo $NaamDefMidAtt1;?></option> <option><?php echo $NaamDefMidAtt2;?></option> <option><?php echo $NaamDefMidAtt3;?></option> </select> </td> </tr> <?php } else{ echo 'U dient in te loggen.'; } ?> </div> <?php get_footer(); ?> Hi guyz, I am looking to create a dymanic comment box for my website where already logged in users can comment on webpages. It is quite a challenge getting to dynamically display only the comments a particular user posted on a web page. What I mean is I would like to be able to click on a page, see only the comments logged users posted on that page, and then post my own comment on that page. At the moment I created a comment box for my webpages but the issue is my posted comments on one particular page is displaying on all web pages with is comment system..This is the problem and it is very difficult to find helpful material hopefully you guyz can come to the rescue. Please guys any help or suggestions are more than welcome. Thanks Kdiamonds Hi So I have successfully set up a website and database where a user can create a listing and view listings on a listing details page. The viewing can only be done, however, only from either from either running a search query from the search form or from clicking one of the listings from the listing table. The listings are not being indexed from the search engines from the direct page, instead from the listing table which is about 3,000 listings, not very user friendly to land on this page and have to go through the table or use the table filter. Here's what I am trying to accomplish: A web page that has a dynamic presence / URL like a Wordpress page: http://www.mysite.com/listing_title/ The title of the page has the listing information in it: This page is about a $listing_title $listing_item listing number $listing_number that is online! Each individual Listing / page is indexed on the search engines and has a direct link to it I am familiar with PHP and have created this site but I am far from an expert! Please give me a code example or link to one because if you just say "do this to this and that" you will totally loose me. Thank you so much for any help. Hey all, This question is coming forth of another topic, but since that topic is not really about this issue, I posted this new topic. Okay, so I made a table, and each row is generated with a WHILE loop. In this while loop, there's also a form generated for each row/record, for updating them seperately. I'm having trouble with naming those forms to process them seperately. I could name them like name="form20110001", with the number being the record's id. But since there can be gaps between id's, how can I retreive them efficiently? And I want them to process all on a single process page, obviously. How can I do this easily? Can someone give me a concise example? Would appreciate it a lot. Thanks I have a product page which populates all my products in one page. I have also a detail page which gives details on a product which i wanted to know. My problem is when I am going to click on the product that I want the detail page shows incorrect product details. I just want one detail product page so that it will be easy to edit the page in the future. I am asking an Idea on how to make one detail page in all of my products.. thanks... This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357949.0 I am looking to add a comment area to pages that are created with data that is pulled off of a database. I am looking for something like the forums on this site, but not as complex. I was thinking about attempting to use a text file to hold the comments for each ID number that is in my database and then displaying those comments when the ID number is called. I'm not sure how I would go about making a function that would search if there was a text file for that ID number and if not to create one. I'm not even sure if this is the best way to go about it but I know if I put all the comments into a database it will get rather large rather quickly. Any pointers and good tutorials would be welcome. Sorry if it sounds as if this post is rambling, I think I need to step away from the computer for a bit. Thanks Hi guys.. 1st post here. I'm pretty new to php.. just a few weeks in. I've gotten pretty decent at making mysql connections and extracting data, but now I'm wanting to take one of my urls that I echo to my page and create a new page. Hoping someone can help... Here's the pictu MY MySQL Setup: I have 1 table called table1. It has 2 columns which a 'Title' & 'Description' My Index.php Page: I connect to mysql. I pull the 'Title' from MySQL and loop it to produce 100 rows of data that fill my index page, as expected. My Problem: I now want to be able to click one of those rows and dynamically create a new page (description.php) that includes the 'Title' & 'Description'. My Progress: I've managed to click a row and create a hyperlink to mysite.com/$title (where 'title' is pulling the 'title' from the mysql db) but I all I get is page not found. My Question: How do I tell description.php to pull the 'Title' and 'Description' and link to it from index.php? My Gratitude: Thanks in advance! Folks, I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image. Got the Idea? Here is the Image link: Quote http://img27.imageshack.us/i/shoppingheader1.jpg/ PHP Variable that holds the Domain name is: $domain All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically... May Anyone Help me with this Please? Cheers Natasha T. Hi all I need to combine these two scripts: Firstly, the following decides which out of the following list is selected based on its value in the mySQL table: <select name="pack_choice"> <option value="Meters / Pack"<?php echo (($result['pack_choice']=="Meters / Pack") ? ' selected="selected"':'') ?>>Meters / Pack (m2)</option> <option value="m3"<?php echo (($result['pack_choice']=="m3") ? ' selected="selected"':'') ?>>Meters / Pack (m3)</option> <option value="Quantity"<?php echo (($result['pack_choice']=="Quantity") ? ' selected="selected"':'') ?>>Quantity</option> </select> Although this works OK, I need it also to show dynamic values like this: select name="category"> <?php $listCategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($categoryReturned=mysql_fetch_array($listCategories)) { echo "<option value=\"".$categoryReturned['name']."\">".$categoryReturned['name']."</option>"; } ?> </select> I'm not sure if this is possible? Many thanks for your help. Pete Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> Some code from my pages ,
Page1 ( Redirecting page )
<html> <title>login_redirect.</title> body> <form name="redirect" action="http://mysite/page2.php" method="post"> <input type="hidden" name="mac" value="$(mac)"> </form> <script language="JavaScript"> <!-- document.redirect.submit(); //--> </script> </body> </html>Page 2 ( select product ) <?php session_start(); ini_set('display_errors',1); error_reporting(E_ALL); include '../lib/config.php'; include '../lib/opendb.php'; // get user mac adres from redirect post page1 $_SESSION['macid'] = $_POST['mac']; // set $macid for other use ( maybe not needed, am learning ) $macid = $_SESSION['macid']; // echo $macid does show mac adress, so variable is not empty here if (!empty($_POST["submit"])) { $product_choice = $_POST['accounttype']; $query= "SELECT AccountIndex, AccountCost, AccountName FROM AccountTypes WHERE AccountIndex='$product_choice'"; $result = mysql_query($query) or die('Query failed. ' . mysql_error()); while($row = mysql_fetch_array($result)) { $_SESSION['AccountIndex'] = $row['AccountIndex']; $_SESSION['AccountCost'] = $row['AccountCost']; $_SESSION['AccountName'] = $row['AccountName']; } header('Location: page3.php'); } // did leave out the other/html/form stuff herePage 3 ( show Session variables ) <?php ini_set('display_errors',1); error_reporting(E_ALL); session_start(); print_r($_SESSION); ?>Now, on page 3 i do see the right session varables, only the "macid" is empty. why ? |