Hello:
I am trying to understand what your are trying to accomplish.
this is just a suggestion.
if  you are using a form to submit the data, then I would change the 
isset($_GET'aid'] to isset($_GET['submitted'])) to test if a form was 
submitted.  The your could use $query="SELECT....VALUE.....    items to be 
place into the database.
if the result is ok then $result=mysql_query($query); the if($result) {
print the results.
That way all of the artist is into one database and you only use one statement 
to display the info from the data base using the aid.
Good luck
see a sample below:
/////////////////////////////////////////////
if(isset($_POST['submitted'])) {//if the form was submitted
    
if(!empty($_POST['artistfname'])) {
    $afn=$_POST['artistfname'];
    } else {
        $_POST['artistfname']=NULL;
        }
        
if(!empty($_POST['artistlname'])) {
    $aln=$_POST['artistlname'];
    } else {
        $_POST['artistlname']=NULL;
        }


if(!empty($_POST['description'])) {
    $desc=$_POST['description'];
    } else {
        $_POST['description']=NULL;
        
        }
        }


 

require_once ('../mysql_connect.php'); // Connect to the database.

 

// Are we looking at a particular artist?

if(empty($errors)) {
    require_once('./connect/mysql_connect.php');
    $query="INSERT INTO artisttable concat(artist_fname, artist_lname) as 
name,price, description) VALUES ('$afn','aln','$price', '$description');
                                        
    [EMAIL PROTECTED]($query);
    if($result) {
    
echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" 
align="center">

<tr>

<td align="left" width="20%"><b>Artist</b></td>

<td align="left" width="20%"><b>Print Name</b></td>

<td align="left" width="40%"><b>Description</b></td>

<td align="right" width="20%"><b>Price</b></td>

</tr>';

 

// Display all the prints, linked to URLs.

$result = mysqli_query ($dbc, $query);

while ($row = mysqli_fetch_array ($result, MYSQL_ASSOC)) {

 

            // Display each record.

            echo "   <tr>

                        <td align=\"left\"><a 
href=\"browse_prints.php?aid={$row['artist_id']}\">{$row['name']}</a></td>

                        <td align=\"left\"><a 
href=\"view_print.php?pid={$row['print_id']}\">{$row['print_name']}</td>

                        <td align=\"left\">{$row['description']}</td>

                        <td align=\"right\">\${$row['price']}</td>

            </tr>\n";

           

} // End of while loop.

 

echo '</table>'; // Close the table.

 

mysqli_close($dbc); // Close the database connection.

include ('./includes/footer.html');

 

?>

 

///////////////////////////////


----- Original Message ----
From: anang tawiah <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, December 11, 2007 12:16:56 PM
Subject: [nyphp-talk] Help in creating multiple columns and rows to display 
product name pice and images





.hmmessage P
{
margin:0px;padding:0px;}
body.hmmessage
{
FONT-SIZE:10pt;FONT-FAMILY:Tahoma;}



I am a relative php amateur who is trying to kind of master
the php 5 syntax and I have using Larry Ulmanns php and mysql 2nd edition
book.  The problem I am facing is that in
the authors example he lists all the results.


  
 

What I want to do for this project is to display the
following product information in rows and columns whereby; 


  
 

i
     could  specify the number of columns
     and rows per page (using php 5 syntax)And finally
     I also want to paginate the result set (using php 5 syntax)

  
 

I know this might sound trivial to most of you ‘Gurus’ on
this list (which is why I finally decided to stop trying to figure it out
myself and ask for help) and I appreciate your help in advance.


  
 

  
 



  
 




<?php # Script 14.6 -
browse_prints.php
 

// This page displays the available
prints (products).
 

  
 

// Set the page title and include
the HTML header.
 

$page_title = 'Browse the Prints';
 

include ('./includes/header.html');
 

  
 

require_once
('../mysql_connect.php'); // Connect to the database.
 

  
 

// Are we looking at a particular
artist?
 

if (isset($_GET['aid'])) {
 

            $aid
= (int) $_GET['aid'];
 

            if
($aid > 0) {
 

                        $query
= "SELECT artists.artist_id, CONCAT_WS(' ', first_name, middle_name,
last_name) AS name, print_name, price, description, print_id FROM artists,
prints WHERE artists.artist_id = prints.artist_id AND prints.artist_id =$aid
ORDER BY prints.print_name";
 

            }
else {
 

                        $query
= "SELECT artists.artist_id, CONCAT_WS(' ', first_name, middle_name,
last_name) AS name, print_name, price, description, print_id FROM artists,
prints WHERE artists.artist_id = prints.artist_id ORDER BY artists.last_name
ASC, prints.print_name ASC";
 

            }
 

} else {
 

            $query
= "SELECT artists.artist_id, CONCAT_WS(' ', first_name, middle_name,
last_name) AS name, print_name, price, description, print_id FROM artists,
prints WHERE artists.artist_id = prints.artist_id ORDER BY artists.last_name 
ASC,
prints.print_name ASC";
 

}
 

  
 

// Create the table head.
 

echo '<table border="0"
width="90%" cellspacing="3" cellpadding="3"
align="center">
 

<tr>
 

<td align="left"
width="20%"><b>Artist</b></td>
 

<td align="left"
width="20%"><b>Print Name</b></td>
 

<td align="left"
width="40%"><b>Description</b></td>
 

<td align="right"
width="20%"><b>Price</b></td>
 

</tr>';
 

  
 

// Display all the prints, linked to
URLs.
 

$result = mysqli_query ($dbc,
$query);
 

while ($row = mysqli_fetch_array
($result, MYSQL_ASSOC)) {
 

  
 

            //
Display each record.
 

            echo
"   <tr>
 

                        <td
align=\"left\"><a
href=\"browse_prints.php?aid={$row['artist_id']}\">{$row['name']}</a></td>
 

                        <td
align=\"left\"><a
href=\"view_print.php?pid={$row['print_id']}\">{$row['print_name']}</td>
 

                        <td
align=\"left\">{$row['description']}</td>
 

                        <td
align=\"right\">\${$row['price']}</td>
 

            </tr>\n";
 

            
 

} // End of while loop.
 

  
 

echo '</table>'; // Close the
table.
 

  
 

mysqli_close($dbc); // Close the
database connection.
 

include ('./includes/footer.html');
 

  
 



?>


  
 




  
 

  
 

Thanks,



 








_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to