| | |
Problem with php and SQL
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 2
Reputation:
Solved Threads: 0
Hi ,
i am trying to retrieve a row of data from a SQL table,but i dont get the results,i just get the variable($stock_code) that i use to search for the row on the screen.
<?php
include "dbaccess.php";
$stock_code=$_POST["txtStock"];
// Insert the required SQL query here.
$query = "SELECT STOCK_CODE FROM STOCKS WHERE STOCK_CODE = '$stock_code'";
$result = submitSQL($query, "read", 0, 0);
for ($i = 0; $i < count($result['STOCK_CODE']); $i++) {
// The for loop is used to display one result per row.
// Preferably use a key field for the count.
// Note: The fieldname must be UPPERCASE
// The next two lines are optional and are used only to help document the table structure
// in the resulting HTML code.
$row_number = $i + 1;
// For each row of SQL output, create a row in an HTML table and then
// add a data element for each field as required.
// Notes: 1. The \n additions are only to clean up the appearance of the HTML code
// but do not affect operation hence they are also optional.
// 2. The lines that contain $result need to have the appropriate field names
// in them in UPPERCASE.
echo "<tr>\n";
echo "<td>";
echo $result['STOCK_CODE'][$i];
echo "</td>\n<td>";
echo $result['STOCK_NAME'][$i];
echo "</td>\n<td>";
echo $result['PRICE'][$i];
echo "</td>\n";
echo $result['QUANTITY_AVAILABLE'][$i];
echo "</td>\n";
echo "</tr>\n";
}
?>
</table>
Any suggestions???
i am trying to retrieve a row of data from a SQL table,but i dont get the results,i just get the variable($stock_code) that i use to search for the row on the screen.
<?php
include "dbaccess.php";
$stock_code=$_POST["txtStock"];
// Insert the required SQL query here.
$query = "SELECT STOCK_CODE FROM STOCKS WHERE STOCK_CODE = '$stock_code'";
$result = submitSQL($query, "read", 0, 0);
for ($i = 0; $i < count($result['STOCK_CODE']); $i++) {
// The for loop is used to display one result per row.
// Preferably use a key field for the count.
// Note: The fieldname must be UPPERCASE
// The next two lines are optional and are used only to help document the table structure
// in the resulting HTML code.
$row_number = $i + 1;
// For each row of SQL output, create a row in an HTML table and then
// add a data element for each field as required.
// Notes: 1. The \n additions are only to clean up the appearance of the HTML code
// but do not affect operation hence they are also optional.
// 2. The lines that contain $result need to have the appropriate field names
// in them in UPPERCASE.
echo "<tr>\n";
echo "<td>";
echo $result['STOCK_CODE'][$i];
echo "</td>\n<td>";
echo $result['STOCK_NAME'][$i];
echo "</td>\n<td>";
echo $result['PRICE'][$i];
echo "</td>\n";
echo $result['QUANTITY_AVAILABLE'][$i];
echo "</td>\n";
echo "</tr>\n";
}
?>
</table>
Any suggestions???
![]() |
Similar Threads
- how to build localhost server using PHP, Apache, MS SQL server 2000 (PHP)
- PHP Form, SQL connectivity issues, please help. (MySQL)
- Problems using a php generator (PHP)
- configure PHP to work with Mysql (MySQL)
- Professional Web design Services (Flash, PHP, SQL, HMTL, CSS) (Web Development Job Offers)
- PHP-MySQL Conn Problem in Win XP (PHP)
- $rs=mysql_query($sql) or die("error in common.inc.php at line 257"); (PHP)
- Problem with foreach when using linking (PHP)
Other Threads in the PHP Forum
- Previous Thread: fopen file mode question
- Next Thread: how to call mysql Procedure in PHP
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





