p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Ch 12 userviewer.php Modifcations FAILURE!~


Message #1 by "Catherine Ng" <sp0okyboo@y...> on Fri, 7 Dec 2001 06:33:25
I tried modifying the userviewer.php example.  I'm

running into a problem though with view_record(). 

list_records() works perfectly but I get no result set

everytime I try the view_record function.  



I think the problem may be that my variable $id is not

getting passed from list_records() to view_record(). 

I followed the book though and seem to locate the

problem.  



Please help.  (code is included below). 





<?php

include "common_db.inc";



function list_records() {

   global $default_dbname;

   global $PHP_SELF;

   global $last;

  

   

   $link_id = db_connect($default_dbname);

   if(!$link_id) error_message(sql_error());



   $query = "SELECT count(*) FROM student";



   $result = mysql_query($query, $link_id);

   if(!$result) error_message(sql_error());

      

   $query_data = mysql_fetch_row($result);

   $total_num_user = $query_data[0];

   if(!$total_num_user) error_message('No User

Found!');

   

   html_header();



  

   $query = "SELECT studentID, first, last FROM

student WHERE last = '$last'";

   

   $result = mysql_query($query, $link_id);   

   if(!$result) error_message(sql_error());



?>



<DIV ALIGN="CENTER">

<TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

<TR>

<TH WIDTH="25%" NOWRAP>

First

      </TH>

<TH WIDTH="25%" NOWRAP>

Last

      </TH>

<TH WIDTH="25%" NOWRAP>Action</TH>

</TR>

<?php



   while($query_data = mysql_fetch_array($result)) {

      $id = $query_data["studentID"];

      $fname = $query_data["first"];

      $lname = $query_data["last"];

      

      echo "<TR>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$id</TD>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$fname</TD>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$lname</TD>\n";

      echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">

<A

HREF=\"javascript:open_window('$PHP_SELF?action=view_record&studentID=$id');\">

View Record</A></TD>\n";

      echo "</TR>\n";

   }



echo "</TABLE>";

echo "</DIV>";

}





function view_record() {

   global $default_dbname;

   global $id;

   global $PHP_SELF;

        

   $link_id = db_connect($default_dbname);

   if(!$link_id) error_message(sql_error());



   $query = "SELECT * FROM student WHERE studentID

'$id'";

   $result = mysql_query($query, $link_id);

   

   if(!$result) error_message(sql_error());

  

   if (mysql_num_rows($result) == 0) echo "Nothing

returned";

   

   $query_data = mysql_fetch_array($result);

   $firstname = $query_data["first"];

   $lastname = $query_data["last"];

   $email = $query_data["email"];

   $grade = $query_data["grade"];

   $team = $query_data["team"];

   $rating = $query_data["rating"];

   $pic = $query_data["pic"];



   html_header();

   echo "<CENTER><H3>

Record for $firstname $lastname

         </H3></CENTER>";



?>

<DIV ALIGN="CENTER">

<TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

<TR>

<TH WIDTH="40%">Name</TH>

<TD WIDTH="60%"><?php echo $firstname ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Email</TH>

<TD WIDTH="60%"><?php echo "<A

HREF=\"mailto:$email\">$email</A>"; ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Grade</TH>

<TD WIDTH="60%"><?php echo $grade ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Team Name</TH>

<TD WIDTH="60%"><?php echo $team ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Rating</TH>

<TD WIDTH="60%"><?php echo $rating ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Picture</TH>

<TD WIDTH="60%"><?php echo $pic ?></TD>

</TR>

</TABLE>

</DIV>



<?php

     

   html_footer();   

}



switch($action) {

   case "view_record":

      view_record();

   break;

   default: 

      list_records();

   break;

}



?>



Message #2 by "Nikolai Devereaux" <yomama@u...> on Fri, 7 Dec 2001 09:52:38 -0800
[crosspost on here and php_howto]



Just taking a really quick look at the source code...



you're passing the student ID variable through the URL as "studentID", but

you're attempting to access it via



global $id;



I didn't see anywhere where you set that global $id to $studentID, or more

specifically $HTTP_GET_VARS['studentID'];



hope this helps,



Nik



-----Original Message-----

From: Catherine Ng [mailto:sp0okyboo@y...]

Sent: Friday, December 07, 2001 6:33 AM

To: beginning php

Subject: [beginning_php] Ch 12 userviewer.php Modifcations FAILURE!~





I tried modifying the userviewer.php example.  I'm

running into a problem though with view_record().

list_records() works perfectly but I get no result set

everytime I try the view_record function.



I think the problem may be that my variable $id is not

getting passed from list_records() to view_record().

I followed the book though and seem to locate the

problem.



Please help.  (code is included below).





<?php

include "common_db.inc";



function list_records() {

   global $default_dbname;

   global $PHP_SELF;

   global $last;





   $link_id = db_connect($default_dbname);

   if(!$link_id) error_message(sql_error());



   $query = "SELECT count(*) FROM student";



   $result = mysql_query($query, $link_id);

   if(!$result) error_message(sql_error());



   $query_data = mysql_fetch_row($result);

   $total_num_user = $query_data[0];

   if(!$total_num_user) error_message('No User

Found!');



   html_header();





   $query = "SELECT studentID, first, last FROM

student WHERE last = '$last'";



   $result = mysql_query($query, $link_id);

   if(!$result) error_message(sql_error());



?>



<DIV ALIGN="CENTER">

<TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

<TR>

<TH WIDTH="25%" NOWRAP>

First

      </TH>

<TH WIDTH="25%" NOWRAP>

Last

      </TH>

<TH WIDTH="25%" NOWRAP>Action</TH>

</TR>

<?php



   while($query_data = mysql_fetch_array($result)) {

      $id = $query_data["studentID"];

      $fname = $query_data["first"];

      $lname = $query_data["last"];



      echo "<TR>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$id</TD>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$fname</TD>\n";

      echo "<TD WIDTH=\"25%\"

ALIGN=\"CENTER\">$lname</TD>\n";

      echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">

<A

HREF=\"javascript:open_window('$PHP_SELF?action=view_record&studentID=$id');

\">

View Record</A></TD>\n";

      echo "</TR>\n";

   }



echo "</TABLE>";

echo "</DIV>";

}





function view_record() {

   global $default_dbname;

   global $id;

   global $PHP_SELF;



   $link_id = db_connect($default_dbname);

   if(!$link_id) error_message(sql_error());



   $query = "SELECT * FROM student WHERE studentID

'$id'";

   $result = mysql_query($query, $link_id);



   if(!$result) error_message(sql_error());



   if (mysql_num_rows($result) == 0) echo "Nothing

returned";



   $query_data = mysql_fetch_array($result);

   $firstname = $query_data["first"];

   $lastname = $query_data["last"];

   $email = $query_data["email"];

   $grade = $query_data["grade"];

   $team = $query_data["team"];

   $rating = $query_data["rating"];

   $pic = $query_data["pic"];



   html_header();

   echo "<CENTER><H3>

Record for $firstname $lastname

         </H3></CENTER>";



?>

<DIV ALIGN="CENTER">

<TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

<TR>

<TH WIDTH="40%">Name</TH>

<TD WIDTH="60%"><?php echo $firstname ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Email</TH>

<TD WIDTH="60%"><?php echo "<A

HREF=\"mailto:$email\">$email</A>"; ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Grade</TH>

<TD WIDTH="60%"><?php echo $grade ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Team Name</TH>

<TD WIDTH="60%"><?php echo $team ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Rating</TH>

<TD WIDTH="60%"><?php echo $rating ?></TD>

</TR>

<TR>

<TH WIDTH="40%">Picture</TH>

<TD WIDTH="60%"><?php echo $pic ?></TD>

</TR>

</TABLE>

</DIV>



<?php



   html_footer();

}



switch($action) {

   case "view_record":

      view_record();

   break;

   default:

      list_records();

   break;

}



?>








$subst('Email.Unsub').



Message #3 by "Robert Laframboise" <robert.laframboise@r...> on Fri, 7 Dec 2001 19:44:18 -0800
What are you using for a server??



Rob

----- Original Message -----

From: "Catherine Ng" <sp0okyboo@y...>

To: "beginning php" <beginning_php@p...>

Sent: Friday, December 07, 2001 6:33 AM

Subject: [beginning_php] Ch 12 userviewer.php Modifcations FAILURE!~





> I tried modifying the userviewer.php example.  I'm

> running into a problem though with view_record().

> list_records() works perfectly but I get no result set

> everytime I try the view_record function.

>

> I think the problem may be that my variable $id is not

> getting passed from list_records() to view_record().

> I followed the book though and seem to locate the

> problem.

>

> Please help.  (code is included below).

>

>

> <?php

> include "common_db.inc";

>

> function list_records() {

>    global $default_dbname;

>    global $PHP_SELF;

>    global $last;

>

>

>    $link_id = db_connect($default_dbname);

>    if(!$link_id) error_message(sql_error());

>

>    $query = "SELECT count(*) FROM student";

>

>    $result = mysql_query($query, $link_id);

>    if(!$result) error_message(sql_error());

>

>    $query_data = mysql_fetch_row($result);

>    $total_num_user = $query_data[0];

>    if(!$total_num_user) error_message('No User

> Found!');

>

>    html_header();

>

>

>    $query = "SELECT studentID, first, last FROM

> student WHERE last = '$last'";

>

>    $result = mysql_query($query, $link_id);

>    if(!$result) error_message(sql_error());

>

> ?>

>

> <DIV ALIGN="CENTER">

> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

> <TR>

> <TH WIDTH="25%" NOWRAP>

> First

>       </TH>

> <TH WIDTH="25%" NOWRAP>

> Last

>       </TH>

> <TH WIDTH="25%" NOWRAP>Action</TH>

> </TR>

> <?php

>

>    while($query_data = mysql_fetch_array($result)) {

>       $id = $query_data["studentID"];

>       $fname = $query_data["first"];

>       $lname = $query_data["last"];

>

>       echo "<TR>\n";

>       echo "<TD WIDTH=\"25%\"

> ALIGN=\"CENTER\">$id</TD>\n";

>       echo "<TD WIDTH=\"25%\"

> ALIGN=\"CENTER\">$fname</TD>\n";

>       echo "<TD WIDTH=\"25%\"

> ALIGN=\"CENTER\">$lname</TD>\n";

>       echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">

> <A

>

HREF=\"javascript:open_window('$PHP_SELF?action=view_record&studentID=$id');

\">

> View Record</A></TD>\n";

>       echo "</TR>\n";

>    }

>

> echo "</TABLE>";

> echo "</DIV>";

> }

>

>

> function view_record() {

>    global $default_dbname;

>    global $id;

>    global $PHP_SELF;

>

>    $link_id = db_connect($default_dbname);

>    if(!$link_id) error_message(sql_error());

>

>    $query = "SELECT * FROM student WHERE studentID

> '$id'";

>    $result = mysql_query($query, $link_id);

>

>    if(!$result) error_message(sql_error());

>

>    if (mysql_num_rows($result) == 0) echo "Nothing

> returned";

>

>    $query_data = mysql_fetch_array($result);

>    $firstname = $query_data["first"];

>    $lastname = $query_data["last"];

>    $email = $query_data["email"];

>    $grade = $query_data["grade"];

>    $team = $query_data["team"];

>    $rating = $query_data["rating"];

>    $pic = $query_data["pic"];

>

>    html_header();

>    echo "<CENTER><H3>

> Record for $firstname $lastname

>          </H3></CENTER>";

>

> ?>

> <DIV ALIGN="CENTER">

> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

> <TR>

> <TH WIDTH="40%">Name</TH>

> <TD WIDTH="60%"><?php echo $firstname ?></TD>

> </TR>

> <TR>

> <TH WIDTH="40%">Email</TH>

> <TD WIDTH="60%"><?php echo "<A

> HREF=\"mailto:$email\">$email</A>"; ?></TD>

> </TR>

> <TR>

> <TH WIDTH="40%">Grade</TH>

> <TD WIDTH="60%"><?php echo $grade ?></TD>

> </TR>

> <TR>

> <TH WIDTH="40%">Team Name</TH>

> <TD WIDTH="60%"><?php echo $team ?></TD>

> </TR>

> <TR>

> <TH WIDTH="40%">Rating</TH>

> <TD WIDTH="60%"><?php echo $rating ?></TD>

> </TR>

> <TR>

> <TH WIDTH="40%">Picture</TH>

> <TD WIDTH="60%"><?php echo $pic ?></TD>

> </TR>

> </TABLE>

> </DIV>

>

> <?php

>

>    html_footer();

> }

>

> switch($action) {

>    case "view_record":

>       view_record();

>    break;

>    default:

>       list_records();

>    break;

> }

>

> ?>

>

>




$subst('Email.Unsub').



Message #4 by "Peer L Plaut" <peer@b...> on Fri, 7 Dec 2001 17:04:40 -0800
I am haveing the same problem... right now as we speak



> "Robert Laframboise" <robert.laframboise@r...> "beginning php" <beginning_php@p...> [beginning_php]
Re: Ch 12 userviewer.php Modifcations FAILURE!~Date: Fri, 7 Dec 2001 19:44:18 -0800

>Reply-To: "beginning php" <beginning_php@p...>

>

>What are you using for a server??

>

>Rob

>----- Original Message -----

>From: "Catherine Ng" <sp0okyboo@y...>

>To: "beginning php" <beginning_php@p...>

>Sent: Friday, December 07, 2001 6:33 AM

>Subject: [beginning_php] Ch 12 userviewer.php Modifcations FAILURE!~

>

>

>> I tried modifying the userviewer.php example.  I'm

>> running into a problem though with view_record().

>> list_records() works perfectly but I get no result set

>> everytime I try the view_record function.

>>

>> I think the problem may be that my variable $id is not

>> getting passed from list_records() to view_record().

>> I followed the book though and seem to locate the

>> problem.

>>

>> Please help.  (code is included below).

>>

>>

>> <?php

>> include "common_db.inc";

>>

>> function list_records() {

>>    global $default_dbname;

>>    global $PHP_SELF;

>>    global $last;

>>

>>

>>    $link_id = db_connect($default_dbname);

>>    if(!$link_id) error_message(sql_error());

>>

>>    $query = "SELECT count(*) FROM student";

>>

>>    $result = mysql_query($query, $link_id);

>>    if(!$result) error_message(sql_error());

>>

>>    $query_data = mysql_fetch_row($result);

>>    $total_num_user = $query_data[0];

>>    if(!$total_num_user) error_message('No User

>> Found!');

>>

>>    html_header();

>>

>>

>>    $query = "SELECT studentID, first, last FROM

>> student WHERE last = '$last'";

>>

>>    $result = mysql_query($query, $link_id);

>>    if(!$result) error_message(sql_error());

>>

>> ?>

>>

>> <DIV ALIGN="CENTER">

>> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

>> <TR>

>> <TH WIDTH="25%" NOWRAP>

>> First

>>       </TH>

>> <TH WIDTH="25%" NOWRAP>

>> Last

>>       </TH>

>> <TH WIDTH="25%" NOWRAP>Action</TH>

>> </TR>

>> <?php

>>

>>    while($query_data = mysql_fetch_array($result)) {

>>       $id = $query_data["studentID"];

>>       $fname = $query_data["first"];

>>       $lname = $query_data["last"];

>>

>>       echo "<TR>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$id</TD>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$fname</TD>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$lname</TD>\n";

>>       echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">

>> <A

>>

>HREF=\"javascript:open_window('$PHP_SELF?action=view_record&studentID=$id');

>\">

>> View Record</A></TD>\n";

>>       echo "</TR>\n";

>>    }

>>

>> echo "</TABLE>";

>> echo "</DIV>";

>> }

>>

>>

>> function view_record() {

>>    global $default_dbname;

>>    global $id;

>>    global $PHP_SELF;

>>

>>    $link_id = db_connect($default_dbname);

>>    if(!$link_id) error_message(sql_error());

>>

>>    $query = "SELECT * FROM student WHERE studentID

>> '$id'";

>>    $result = mysql_query($query, $link_id);

>>

>>    if(!$result) error_message(sql_error());

>>

>>    if (mysql_num_rows($result) == 0) echo "Nothing

>> returned";

>>

>>    $query_data = mysql_fetch_array($result);

>>    $firstname = $query_data["first"];

>>    $lastname = $query_data["last"];

>>    $email = $query_data["email"];

>>    $grade = $query_data["grade"];

>>    $team = $query_data["team"];

>>    $rating = $query_data["rating"];

>>    $pic = $query_data["pic"];

>>

>>    html_header();

>>    echo "<CENTER><H3>

>> Record for $firstname $lastname

>>          </H3></CENTER>";

>>

>> ?>

>> <DIV ALIGN="CENTER">

>> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

>> <TR>

>> <TH WIDTH="40%">Name</TH>

>> <TD WIDTH="60%"><?php echo $firstname ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Email</TH>

>> <TD WIDTH="60%"><?php echo "<A

>> HREF=\"mailto:$email\">$email</A>"; ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Grade</TH>

>> <TD WIDTH="60%"><?php echo $grade ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Team Name</TH>

>> <TD WIDTH="60%"><?php echo $team ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Rating</TH>

>> <TD WIDTH="60%"><?php echo $rating ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Picture</TH>

>> <TD WIDTH="60%"><?php echo $pic ?></TD>

>> </TR>

>> </TABLE>

>> </DIV>

>>

>> <?php

>>

>>    html_footer();

>> }

>>

>> switch($action) {

>>    case "view_record":

>>       view_record();

>>    break;

>>    default:

>>       list_records();

>>    break;

>> }

>>

>> ?>

>>

>>




>$subst('Email.Unsub').

>

>












Peer L. Plaut

Head Baldie

baldmen.com

220-5 South Swing Road

Greensboro, NC 27409





------------------------------------------------------------

Baldmen.com is now offering FREE  E-mail!! http://www.baldmen.com

It's FAST, It's Permanent, It's ISP independent! .....Sign up today

Message #5 by "Nikolai Devereaux" <yomama@u...> on Fri, 7 Dec 2001 17:20:05 -0800

Peer, did you see my original reply to Catherine?  If not, I'll restate my

info here.





And Robert, why would Catherine's server have anything to do with it?





Basically, you have this situation:



If you're having a problem with view_record(), but list_records() works

perfectly, then you can ignore all of list_records and just LOOK AT

view_record()!!



Let's do that now, shall we?  View record is called when userview.php is

called with "action=view_record", correct?  Yes, of course it is.



So what's the link that requests the page with action=view_record?



javascript:open_window('$PHP_SELF?action=view_record&studentID=$id');



What do you notice?  We're passing TWO GLOBAL PARAMETERS here via the URL.

     variable        value

1)   action     =  "view_record"   // Ok, nothing new there.

2)   studentID  =  $id             // Looks okay so far, since $id

                                      works for list_records



So let's now look at the function view_record().  Here's the first three

lines:



function view_record() {

   global $default_dbname;

   global $id;



Wait a moment!!  What the heck is $id??  Where is that passed??  It's NOT!

The variable name we're passing is "studentID" not "id".



You need to change all the $id's you're using in view_record() to $studentID

before this will work, otherwise PHP will assume a global variable named

"$id" exists and is equal to NULL.





Nik





-----Original Message-----

From: Peer L Plaut [mailto:peer@b...]

Sent: Friday, December 07, 2001 5:05 PM

To: beginning php

Subject: [beginning_php] Re: Ch 12 userviewer.php Modifcations FAILURE!~





I am haveing the same problem... right now as we speak



> "Robert Laframboise" <robert.laframboise@r...> "beginning php"

<beginning_php@p...> [beginning_php] Re: Ch 12 userviewer.php

Modifcations FAILURE!~Date: Fri, 7 Dec 2001 19:44:18 -0800

>Reply-To: "beginning php" <beginning_php@p...>

>

>What are you using for a server??

>

>Rob

>----- Original Message -----

>From: "Catherine Ng" <sp0okyboo@y...>

>To: "beginning php" <beginning_php@p...>

>Sent: Friday, December 07, 2001 6:33 AM

>Subject: [beginning_php] Ch 12 userviewer.php Modifcations FAILURE!~

>

>

>> I tried modifying the userviewer.php example.  I'm

>> running into a problem though with view_record().

>> list_records() works perfectly but I get no result set

>> everytime I try the view_record function.

>>

>> I think the problem may be that my variable $id is not

>> getting passed from list_records() to view_record().

>> I followed the book though and seem to locate the

>> problem.

>>

>> Please help.  (code is included below).

>>

>>

>> <?php

>> include "common_db.inc";

>>

>> function list_records() {

>>    global $default_dbname;

>>    global $PHP_SELF;

>>    global $last;

>>

>>

>>    $link_id = db_connect($default_dbname);

>>    if(!$link_id) error_message(sql_error());

>>

>>    $query = "SELECT count(*) FROM student";

>>

>>    $result = mysql_query($query, $link_id);

>>    if(!$result) error_message(sql_error());

>>

>>    $query_data = mysql_fetch_row($result);

>>    $total_num_user = $query_data[0];

>>    if(!$total_num_user) error_message('No User

>> Found!');

>>

>>    html_header();

>>

>>

>>    $query = "SELECT studentID, first, last FROM

>> student WHERE last = '$last'";

>>

>>    $result = mysql_query($query, $link_id);

>>    if(!$result) error_message(sql_error());

>>

>> ?>

>>

>> <DIV ALIGN="CENTER">

>> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

>> <TR>

>> <TH WIDTH="25%" NOWRAP>

>> First

>>       </TH>

>> <TH WIDTH="25%" NOWRAP>

>> Last

>>       </TH>

>> <TH WIDTH="25%" NOWRAP>Action</TH>

>> </TR>

>> <?php

>>

>>    while($query_data = mysql_fetch_array($result)) {

>>       $id = $query_data["studentID"];

>>       $fname = $query_data["first"];

>>       $lname = $query_data["last"];

>>

>>       echo "<TR>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$id</TD>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$fname</TD>\n";

>>       echo "<TD WIDTH=\"25%\"

>> ALIGN=\"CENTER\">$lname</TD>\n";

>>       echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">

>> <A

>>

>HREF=\"javascript:open_window('$PHP_SELF?action=view_record&studentID=$id')

;

>\">

>> View Record</A></TD>\n";

>>       echo "</TR>\n";

>>    }

>>

>> echo "</TABLE>";

>> echo "</DIV>";

>> }

>>

>>

>> function view_record() {

>>    global $default_dbname;

>>    global $id;

>>    global $PHP_SELF;

>>

>>    $link_id = db_connect($default_dbname);

>>    if(!$link_id) error_message(sql_error());

>>

>>    $query = "SELECT * FROM student WHERE studentID

>> '$id'";

>>    $result = mysql_query($query, $link_id);

>>

>>    if(!$result) error_message(sql_error());

>>

>>    if (mysql_num_rows($result) == 0) echo "Nothing

>> returned";

>>

>>    $query_data = mysql_fetch_array($result);

>>    $firstname = $query_data["first"];

>>    $lastname = $query_data["last"];

>>    $email = $query_data["email"];

>>    $grade = $query_data["grade"];

>>    $team = $query_data["team"];

>>    $rating = $query_data["rating"];

>>    $pic = $query_data["pic"];

>>

>>    html_header();

>>    echo "<CENTER><H3>

>> Record for $firstname $lastname

>>          </H3></CENTER>";

>>

>> ?>

>> <DIV ALIGN="CENTER">

>> <TABLE BORDER="1" WIDTH="90%" CELLPADDING="2">

>> <TR>

>> <TH WIDTH="40%">Name</TH>

>> <TD WIDTH="60%"><?php echo $firstname ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Email</TH>

>> <TD WIDTH="60%"><?php echo "<A

>> HREF=\"mailto:$email\">$email</A>"; ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Grade</TH>

>> <TD WIDTH="60%"><?php echo $grade ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Team Name</TH>

>> <TD WIDTH="60%"><?php echo $team ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Rating</TH>

>> <TD WIDTH="60%"><?php echo $rating ?></TD>

>> </TR>

>> <TR>

>> <TH WIDTH="40%">Picture</TH>

>> <TD WIDTH="60%"><?php echo $pic ?></TD>

>> </TR>

>> </TABLE>

>> </DIV>

>>

>> <?php

>>

>>    html_footer();

>> }

>>

>> switch($action) {

>>    case "view_record":

>>       view_record();

>>    break;

>>    default:

>>       list_records();

>>    break;

>> }

>>

>> ?>

>>

>>




>$subst('Email.Unsub').

>

>




$subst('Email.Unsub').









Peer L. Plaut

Head Baldie

baldmen.com

220-5 South Swing Road

Greensboro, NC 27409





------------------------------------------------------------

Baldmen.com is now offering FREE  E-mail!! http://www.baldmen.com

It's FAST, It's Permanent, It's ISP independent! .....Sign up today






$subst('Email.Unsub').




  Return to Index