Re: grab table row

From: Date: Wed, 05 Jul 2000 16:55:20 +0000
Subject: Re: grab table row
Groups: php.general 
Request: Send a blank email to php-general+get-5005@lists.php.net to get a copy of this message
What does your SQL query look like? What you should do is narrow the data that you want to print down in the SQL statement and select all records (select * where WHATEVER order by WHATEVER, etc) and then call the particular row and cell by using mysql_fetch_row(). Here is some code that I have for a table I have done. Some variables might only be for this code but you should be able to get the idea. //Get stuff from Metro Admin table $query_metro_admin = "SELECT * FROM $all_admin WHERE id=$thismonth-1"; $result_metro_admin = mysql_query($query_metro_admin); $row_metro = mysql_fetch_row($result_metro_admin); /* Select all records from the database*/ $metro_query = "SELECT * FROM $all_table; $metro_result = MYSQL_QUERY($metro_query); //set a temporary id $temp_id = ($metro_result); //set row number mysql_data_seek($metro_result, $temp_id-1); //go to the appropriate row $row = mysql_fetch_row($metro_result); $row[2] += $act_deposits; //act_deposits $row[3] += $cyls; //cyls $row[4] += $gallons; //gallons $row[5] += $revenue; //revenue Hope this helps, Kevin kevsurf@hotmail.com
From: "Rod Goodwin" <rodneyg@magma.ca> To: <php-general@lists.php.net> Subject: [PHP] grab table row Date: Wed, 5 Jul 2000 12:40:38 -0400 Hi, I am trying to get around using fishcart, or a JavaScript cart, which is more than I need. Essentially, I want to grab a row and create a hyperlink on the fly. This last column's link should be bring up a new page with the full record details. I am using mysql/php3, and would prefer to stay away from JavaScript. I have had trouble with this sprinkling a link into a table (utilizing that row) I have lurked, and scoured and can find nothing. Thanks in advance! My code is as follows // create header row
     print("<TR>\n");
     print("<TD BGCOLOR=\"#CCCCCC\"><B>Chicken breed</B></TD>\n");
     print("<TD BGCOLOR=\"#CCCCCC\"><B>Weight</B></TD>\n");
     print("<TD BGCOLOR=\"#CCCCCC\"><B>Colour</B></TD>\n");
     print("</TR>");
//start data printing to table format if ($row = mysql_fetch_array($query))
        {
                  do {
                      print ("<TR>"); // start row
                      print("<TD> <FONT SIZE=\"-4\">\n");
                      print $row["CHICKEN"];
                      print ("</TD>");
                      print("<TD> <FONT SIZE=\"-4\">\n");
                      print $row["WEIGHT"];
                      print ("</TD>");
                      print("<TD> <FONT SIZE=\"-4\">\n");
                      print $row["COLOUR"];
                      print ("</TD>");
                      print ("</TR>");    // end row
                     } while ($row  =  mysql_fetch_array($query));
         }
       else {print "Sorry, no records were found!";}
       print ("</TABLE>");     //end table
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

« previous php.general (#5005) next »