2010-10-05 100 views
1

这是我的网页:从数据库中显示的数据 - 包括图像

http://www.autoweek62.uni.cc/carprice.php

下面是它的源代码:

<?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>'); 
?> 

它显示了,但我不知道如何让它以类似于此的方式显示:

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_S equenceNum_Int32 | 0 & N = 2994 + 2951 + 4294961316 + 4294843565 & TabId = 1407343

[没有联系,因为我不能发布超过1是新这里]

(尽管我的是简单地制造商,型号,身体风格和价格列表,不像上面的链接复杂!)

我已经谷歌搜索一些灵感,但尽管尝试没有任何远。我不是在寻找即时答案,但欢迎任何解决方案!

显示图像是最棘手的部分......我把JPG存储在服务器上,试图让它们显示是一个问题。

欢迎所有帮助!

+0

看起来像你在做错什么。 muisuse数据库,表格和图片 – 2010-10-05 14:37:59

+0

您可以举一个存储在数据库的图像表中的示例吗?这可能只是我,但我不确定我了解你如何存储图像。 – Vache 2010-10-05 14:41:43

+1

他将图像存储在数据库中(作为斑点)。如果你愿意,你可以这样做,但是在检索它们时复制Web服务器提供的工具是很多工作。 – 2010-10-05 15:01:25

回答

0

您可以尝试制作一个单独的脚本,仅返回图像。

在该脚本中,您从数据库中检索图像,输出MIME类型标题,然后输出原始图像数据。在您的主要HTML输出脚本中,您只需编写<img src="getImage.php?id=1234" />