I am trying to learn php, so far I have managed to write info to my database using forms, and display the info from the page.
My next step is to learn to take the info and make them into URL's:
I have no idea what I am doing with this next step, can anyone help?
index.php:
<?
include("config.php");
?>
<html>
<form method="post" action="submit.php">
<TABLE>
<TR>
<TD>Title:</TD>
<TD><INPUT TYPE='TEXT' NAME='title' VALUE='' size=60></TD>
</TR>
<TR>
<TD>Description:</TD>
<TD><INPUT TYPE='TEXT' NAME='description' VALUE='' size=60></TD>
</TR><br>
<TR>
<TD>Category:</TD>
<TD><INPUT TYPE='TEXT' NAME='category' VALUE='' size=60></TD>
</TR><br>
<TR>
<TD></TD><br>
<TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>
<html>
submit.php
<?
//initilize PHP
if($_POST['submit']) //If submit is hit
{
include("config.php");
//convert all the posts to variables:
$title = $_POST['title'];
$description = $_POST['description'];
$category = $_POST['category'];
//Insert the values into the correct database with the right fields
//mysql table = gamepage
//table columns = id, title, description, category
//post variables = $title, $description, '$category
$result=MYSQL_QUERY("INSERT INTO gamepage (id,title,description,category)".
"VALUES ('NULL','$title', '$description', '$category')");
//confirm
echo "Query Finished";
}
?>
gamepage.php:
<?
include("config.php");
$result = mysql_query("SELECT * FROM gamepage");
if (!$result) {
echo("<b>Error performing query: " . mysql_error() . "</b>");
exit();
}
while ($row = mysql_fetch_array($result) ) {
$title = $row["title"];
[COLOR="Red"]$id = $row["id"];[/COLOR]
[COLOR="Red"]echo("<p><a href="gamepage.php?id=$id">$title</a></p>");[/COLOR]
}
?>
Ok, what I want to be able to do is when you land on gamepage.php it will show the Titles of the games- I want the game title to be a URL and when you click on it the rest of the info for the game will be displayed.
The urls's would look something like mydomain.com/gamepage.php?id=1 etc.
the table name is gamepage
and the table rows are:
id
title
description
category
Can anyone help me finish this code?
I am trying to keep this in the most basic form, so that I can build on this as I learn more.
Thanks.