Jump to content

How to generate php pages?


xuniter

Recommended Posts

ok now i will ask correctly sry about previous post, so how to make that the page will show different information using variables, example :

 

www.domain.com/product.php?productid=42333

www.domain.com/product.php?productid=56326

 

It's the same page but it shows different info. Where can i read something about it or how it is called so i could search it

 

Thank you very much

Link to comment
Share on other sites

a VERY rough idea of how to do it. (NOTE - this example does NOT address any security issues)...

 

The form page:

 

<?PHP
/* connect to your database */
include('db.php');

/* create the query */
$query = "SELECT id, product_name FROM FROM your_table_name WHERE id = '$productid'";

/* execute the query */
$result = mysql_query($query);

/* display your form */
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Select A Product</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<form action="processpage.phpt" method="get">
<select name="productid">
	<?PHP
	while($row = mysql_fectch_array($result)) {
		?>
		<option value="<?PHP echo $row['id']; ?>"><?PHP echo $row['product_name']; ?></option><br>
	<?PHP
	}
	?>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>

 

The processing page:

<?PHP
/* put the passed value into a variable */
$productid = $_GET['productid'];

/* connect to your database */
include('db.php');

/* create your query */
$query = "SELECT product_name, description, price, quantity, image FROM your_table_name WHERE id = '$productid'";

/* execute the query */
$result = mysql_query($query);

/* put the results into an array */
$row = mysql_fetch_array($result);

/* display the information how you want */
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Information for <?PHP echo $row['product_name']; ?></title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">
Product name : <?PHP echo $row['product_name']; ?><br>
<IMG src="<?PHP echo $row['image']; ?>"><br>
Product price :  <?PHP echo $row['price']; ?><br>
Quantity Avail :  <?PHP echo $row['quantity']; ?><br>
Product description :  <?PHP echo nl2br($row['description']); ?><br>
</body>
</html>


(Passing variables via GET)

Link to comment
Share on other sites

ok now i will ask correctly sry about previous post, so how to make that the page will show different information using variables, example :

 

www.domain.com/product.php?productid=42333

www.domain.com/product.php?productid=56326

 

It's the same page but it shows different info. Where can i read something about it or how it is called so i could search it

 

Thank you very much

 

That is also covered in the link I provided.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.