Hi All
I am new to PHP and i am trying to create a dynamicaly generated page for a localhost site i am making.
I have the databases working fine but i would like to be able to click on a button eg View and have it take me to a different page
Below is the code i have so far please help (IF YOU NEED MORE INFO PLEASE JUST ASK)
Thanks in advance
Database Page (Section)
{
echo "<tr>";
echo "<td><center>" . $row['ID'] . "</td>";
echo "<td>" . $row['Title'] . "</td>";
echo "<td><center>" . $row['Certificate'] . "</td>";
echo "<td>" . $row['Director'] . "</td>";
echo "<td><center>" . $row['Released'] . "</td>";
echo "<td><center>" . $row['Notes'] . "</td>";
echo "<td><a href=\"View.php?id=".$row[ID]."\">View</a>";
echo "</tr>";
}
Dynamic Page
<?php
$db = mysql_connect("", "", "");
mysql_select_db("",$db);
$result = mysql_query("SELECT * FROM WHERE id=$ID",$db);
$row = mysql_fetch_array($result);
echo "Title: ".$row["Title"];
?>
I have removed the Database details
My Columns are - Title , Director, Certficate, Released and Notes
Please Help Guys
Thank you
PHP Dynamic Pages
Moderator: General Moderators
-
tomtek1990
- Forum Newbie
- Posts: 2
- Joined: Mon Mar 08, 2010 12:10 pm
Re: PHP Dynamic Pages
BTW when i click the View Button a page loads with the wanted result in the address bar I.E it says View.php?id=14
then it show Title: with no results from the Database
Please Help

then it show Title: with no results from the Database
Please Help
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP Dynamic Pages
Where is $ID coming from? You need to read up on the $_GET and $_POST superglobals. Also, you don't have a table name in your query. Assuming that you have an `id` column and that you have a record with id = 14, then:
Code: Select all
$ID = (int)$_GET['id'];
$result = mysql_query("SELECT * FROM table_name WHERE id=$ID",$db);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: PHP Dynamic Pages
Also you need to use mysql_fetch_assoc() instead of mysql_fetch_array() is you want an associative array instead of a numerically indexed array.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP Dynamic Pages
mysql_fetch_array() fetches both by default.John Cartwright wrote:Also you need to use mysql_fetch_assoc() instead of mysql_fetch_array() is you want an associative array instead of a numerically indexed array.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.