Sending Data From One Page To Another

Hello. This is my first post here. Lovely site.

I am trying to create a product catalog. One page will have a list of all the products (gauges, in this case). The attributes of every item will be in a MySQL databse. I want them all to link to the same page, such as product_info.php, but I will have to attatch ?item_num=xxx. I have been unable to find out how to get the product_info.php page to pick up this information. I just picked up PHP yesterday, and that’s the last piece in the puzzle for me to be able to do my project, as far as I see.

If anyone can point me to a specific resource, or give me any advice, I’d appreciate it greatly.

Thanks!

You want the $_GET[] variable – it’s where the url variables end up. The PHP manual at php.net is usually the best primary resource.

Excellent PHP Tutorials for the shiny new beginner:

Full listing of tutorials:
http://codewalkers.com/tutorials.php?c=5

First project (install software, create database, query database):
“Creating Dynamic Websites with PHP and MySQL”
http://codewalkers.com/tutorials/9/1.html

Musts for the beginner (suggested order):

  1. Tour of Decision Making Structures
  2. PHP Control structures
  3. PHP strings Primer
  4. An Overview of Arrays
  5. PHP Debugging Tutorial
  6. Working with Forms in PHP

Those tutorials will go a long way for a True beginner in PHP.

I’ve looked on all those sites before, and what I’m trying to do seems to be mentioned in passing, or indirectly, with a slightly similar project that only sort of applies. But from what I’ve been able to gleam, this is what I’ve come up with:

[code]

<? if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 1000; } $db_name = "BataDase"; $table_name = "my_music"; $connection = @mysql_connect("localhost", "user", "pass") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); $sql = "SELECT * FROM $table_name WHERE id = '$id'"; $result = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $title = stripslashes($row['title']); } ?> test display

<? print ($title); ?>

[/code]
<html> 
<title>test display</title> 
<body> 

<? 
   if (isset($_GET['id'])) { 
     $id = $_GET['id']; 
   } else { 
     $id = 1000; 
   } 


   $db_name = "BataDase"; 
   $table_name = "my_music"; 
    
   $connection = @mysql_connect("localhost", "user", "pass") or die(mysql_error()); 
   $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); 

   $sql = "SELECT * FROM $table_name WHERE id = '$id'"; 
   $result = @mysql_query($sql,$connection) or die(mysql_error()); 

    
   while ($row = mysql_fetch_row($result)) 
   { 
       print "<h1>$title</h1>"; 
   } 
?> 
</body> 
</html>

The way you currently have it only prints the last one. In the loop it will print out EACH one. Get it?

I’ve figured it out, w/ a little help.

[code]

<? if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 1000; } $db_name = "BataDase"; $table_name = "my_music"; $connection = @mysql_connect("mysql7.secureserver.net", "BataDase", "llogeri") or die(mysql_error()); $db = mysql_select_db($db_name, $connection) or die(mysql_error()); $sql = "SELECT * FROM $table_name WHERE id = $id"; $result = mysql_query($sql,$connection) or die(mysql_error()); $row = mysql_fetch_assoc($result); $string=join(',',$row); ?> test display

<? echo $row['title']; ?>


<? echo $row['artist_fn']; ?>
<? echo $row['artist_ln']; ?>


<? echo $row['my_notes']; ?> [/code]

This does exactly what I need it to do. Thanks, everybody.

Sponsor our Newsletter | Privacy Policy | Terms of Service