Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, April 2, 2016

PHP - How to Create Dynamic URLs?

a dynamic page would be something like that..

Answer by Kip Shaw for PHP - How to Create Dynamic URLs?


Here is the pertinent code for extracting a list of events in November from a table named calendar, with each event having a link to a page called event.php and with the event's id field appended to the end of the url:

$result = mysql_query("SELECT * FROM calendar WHERE sort_month='11'");    while($row = mysql_fetch_array($result))    {echo    "".$row['event_name'].""    ;}    

And here is the pertinent code on the event.php page. Note the row numbers in brackets depends on the placement of such in your table, remembering that the first row (field) would have the number 0 inside the brackets:

$id = $_GET['id'];    $sql = "select * from calendar where id = $id";    $result = mysql_query($sql, $con);    if ($result){    $row = mysql_fetch_row($result);    $title = $row[12];    $content = $row[7];    }    ?>              <?php echo $title ?>            

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.