66 951
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #45697 in AJAX | JavaScript | HTML | PHP for talha

Question #45697
i want total database value on array loop but wht i do mistake i dont know please help me (without query)

<?php

include("db.php");

$result = mysql_query("SELECT FROM trasur_com_pk");

while ($test = mysql_fetch_array($query)) {

$Sno = $test['Sno'];
echo "<tr align='center'>";
echo"<td><font color='black'>" .$test['Sno']."</font></td>";
echo"<td><font color='black'>" .$test['Transporter']."</font></td>";
echo"<td><font color='black'>". $test['Vehicle']. "</font></td>";
echo"<td><font color='black'>". $test['Loaded_Product']. "</font></td>";
echo"<td><font color='black'>". $test['Tonnage_loading_Point']. "</font></td>";
echo"<td><font color='black'>" .$test['Tonnage_Unloading_Point']."</font></td>";
echo"<td><font color='black'>" .$test['PSA_number']."</font></td>";
echo"<td><font color='black'>" .$test['Shipment_Date_PSA']."</font></td>";
echo"<td><font color='black'>" .$test['Loading_Origin']."</font></td>";
echo"<td><font color='bla
Expert's answer
Code (db.php)
<?php
define("HOST", "localhost");
define("USER", "root");
define("PASSWORD", "");
define("DATABASE", "45697");
 
mysql_connect(HOST, USER, PASSWORD) or
die("Could not connect:". mysql_error());
mysql_select_db(DATABASE);
?>
There is few mistakein your file. It should be
$result = mysql_query("SELECT * FROMtest");
instead of
$result = mysql_query("SELECT FROMtrasur_com_pk");
and
while ($test = mysql_fetch_array($result, MYSQL_ASSOC)) {
instead of
while ($test = mysql_fetch_array($query)) {
Code (index.php)
<?php
include("db.php");
 
$result = mysql_query("SELECT * FROMtest");
 
while ($test = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<table>";
echo "<tbody>";
echo "<tralign='center'>";
echo"<td><fontcolor='black'>" .$test['Sno']."</font></td>";
echo"<td><fontcolor='black'>" .$test['Transporter']."</font></td>";
echo"<td><fontcolor='black'>". $test['Vehicle']. "</font></td>";
echo"<td><fontcolor='black'>". $test['Loaded_Product']. "</font></td>";
echo"<td><fontcolor='black'>". $test['Tonnage_loading_Point']. "</font></td>";
echo"<td><fontcolor='black'>" .$test['Tonnage_Unloading_Point']."</font></td>";
echo"<td><fontcolor='black'>" .$test['PSA_number']."</font></td>";
echo"<td><fontcolor='black'>" .$test['Shipment_Date_PSA']."</font></td>";
echo"<td><fontcolor='black'>" .$test['Loading_Origin']."</font></td>";
echo "</tr>";
echo "</tbody>";
echo "</table>";
}
?>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions