Displaying data from databases - including images
This is my webpage:
http://www.autoweek62.uni.cc/carprice.php
Here is the source code for it:
<?php
$dbname = "autoweek_auto1";
$loginname = "autoweek_root";
$loginpass = "PASSWORD (not my real one)";
$dbhost = "localhost";
echo('<html><body bgcolor="#FFFFFF">');
echo('<font face="arial" size="+4"><center>');
echo("Database $dbname");
$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:
// [i] == 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>Table $arr_tablenames[$i] </h2></center>");
echo('<table align="center" border="1"><tr>');
$result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
echo("<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 < $arr_num_fields[$i]; $ii++) {
echo("<td>");
echo $record[$ii];
echo("</td>");
}
echo("</tr>");
}
echo("</table>");
}
echo('</body></html>');
?>
It displays, but I'm not sure how to get it to display in a manner similar to this:
redbook.com.au/new-cars/results.aspx?Ns=p_Make_String|0||p_ClassificationType_String|0||p_Family_String|0||p_Year_String|1||p_SequenceNum_Int32|0&N=2994+2951+4294961316+4294843565&TabId=1407343
[not linked since I can't post more than 1 being new here]
(although mine is simply the make, model, bodystyle and prices as a list, not as complicated as the link above!)
I've Googled for some inspiration, but despite trying haven't got any far. I'm not looking for an instant answer, but any solutions are welcomed!
Displaying images is the trickiest part... I have the JPGs stored on the server, trying to get them to display is a problem.
开发者_运维问答All help is welcomed!
You could try making a separate script that returns just the image.
In that script you retrieve the image from the database, output mime-type header and then the raw image data. In your main HTML outputting script you just write <img src="getImage.php?id=1234" />
精彩评论