Page 1 of 1

Displaying data in a Web Page

Posted: Wed Apr 30, 2003 5:48 am
by rashpal
Hello,

I trying to display data from mysql into a webpage, although the data is there, it's not displaying the tables in the correct location. I've included the code so that you can have a good laugh!!!

But seriously it can't be that difficult? can it!
Can anyone help?

Regards,

RA

<?php
?>

<?php

$dbname = "cwafsmi";
$loginname = "root";
$loginpass = "xxxx";
$dbhost = "xxx.xxx.xxx.xxx.";

echo('<html><body bgcolor="#3399FF">');
echo('<font face="arial" size="+4"><center>');


$id_link = @mysql_connect($dbhost, $loginname, $loginpass);

$tables = mysql_list_tables($dbname, $id_link);

$num_tables = mysql_num_rows($tables);

// store table names in an array
$arr_tablenames[] = '';

// store number of fields per table(index 0,1,2..) in an array
$arr_num_fields[] = '';
for ($i=0; $i < $num_tables; $i++) {
$arr_tablenames[$i] = mysql_tablename($tables, $i);
$arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link));
}

// store field names in a multidimensional array:
// == table number, [ii] == field number for that table
for ($i=0; $i < $num_tables; $i++) {
for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
$result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
$hash_field_names[$i][$ii] = mysql_field_name($result, $ii);
}
}

// for ($i=0; $i < $num_tables; $i++) {
echo("<center><h2>CWAFS Management Information </h2></center>");
echo('<table align="center" border="1"><tr>');
$result = mysql_db_query($dbname, "select SubName, ConName, AgentCode, BchName, MPPpols, PPPpols, LRMpols, BMPfactor, IPfactor, SuccessFactor from weblife where Datamonth = 'APR2003' and Status = 'WR' order by SubName, ConName, BchName", $id_link);
//for ($ii=0; $ii < 11; $ii++) {
echo("<th>Subsidiary</th>");
echo("<th>Consultant</th>");
echo("<th>Code</th>");
echo("<th>Branch</th>");
echo("<th>MPP</th>");
echo("<th>PPP</th>");
echo("<th>LRM</th>");
echo("<th>BMP Factor</th>");
echo("<th>IP Factor</th>");
echo("<th>Success Factor</th>");
// echo $hash_field_names[$i][$ii];
// echo("</th>");
//}
echo("</tr><tr>");
$number_of_rows = @mysql_num_rows($result);
for ($iii = 0; $iii < $number_of_rows; $iii++) {
$record = @mysql_fetch_row($result);
for ($ii=0; $ii < 11; $ii++) {
echo("<td>");
echo $record[$ii];
echo("</td>");
}
echo("</tr>");
}
echo("</table>");
// }



echo('</body></html>');
?>
<html>

<head>
<title>beecdata</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body>

<div align="center">
<center>
<table border="0" width="742" height="717">
<tr>
<td align="center" height="109" width="135"> <img border="0" src="LOGOS/Bairstow%20Eves.jpg" width="115" height="71"></td>
<td align="center" height="109" width="597"> <p><font color="#8080FF"><strong>BAIRSTOW
EVES CENTRAL</strong></font></p>
<p><strong><font color="#0000A0">MANAGEMENT INFORMATION</font></strong></p></td>
</tr>
<tr>
<td height="22" colspan="2" width="734"><img border="0" src="Images/white.gif" width="734" height="20"></td>
</tr>
<tr>
<td height="21" width="138">&nbsp;&nbsp;&nbsp; </td>
<td height="21" width="596"><form name="form1" method="post" action="">
</form> </td>
</tr>
<tr>
<td width="133" height="61" valign="top"></td>
<td height="1" rowspan="7" width="595">&nbsp;</td>
</tr>
<tr>
<td width="133" height="22" valign="top"><a href="Subsidairys/beecentral1.htm"><img border="0" src="Images/home.png" width="130" height="21"></a></td>
</tr>
<tr>
<td width="133" height="24" valign="top"><img src="Images/contactus.png" width="129" height="21"></td>
</tr>
<tr>
<td width="133" height="13" valign="top"><img src="Images/feedback.png" width="129" height="21"></td>
</tr>
<tr>
<td width="133" height="1" valign="top"><img src="Images/links.png" width="129" height="21"></td>
</tr>
<tr>
<td width="133" height="23" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="133" height="344" valign="top"></td>
</tr>
<tr>
<td width="133" height="21"></td>
<td height="21" width="595"><div align="center"><span style='font-size:7.5pt;font-family:Arial;color:#AAAAAA'>©
Copyright 2003. All rights reserved. Contact: </span><font color="#0000FF"><a href="mailto:systems@cwams.co.uk"><span style='font-size: 7.5pt; font-family: Arial'>systems@cwafs.co.uk</span></a>
</font><span style='font-size:7.5pt;font-family:Arial;color:#AAAAAA'>
&nbsp;&nbsp; </span></div></td>
</tr>
</table>
</center>
</div>

</body>

</html>


[/url][/list]

remove error suppression

Posted: Wed Apr 30, 2003 11:28 am
by phpScott
I would start by removing the @ symbos from the front of the

Code: Select all

@mysql_connect
@mysql_num_rows
@mysql_fetch_row
to see if there is a mysql error occuring some where that I not displaying the results.
another thing to help clean up your code a bit is to remove all the () brackets around your echo statements as they are not neede.

phpScott