Warning: Invalid argument supplied for foreach() in

前端 未结 3 1784
再見小時候
再見小時候 2021-01-23 02:43
$results = mysql_query(\"select * from classpics\");

foreach($results as $uno) {
    echo \'

        
相关标签:
3条回答
  • 2021-01-23 02:51

    mysql_query returns resource, not an array or any other container. Use mysql_fetch_assoc() to fetch the next result.

    while ($uno = mysql_fetch_assoc($result)) {
        echo '<td valign="middle" align="center"><a class="neutral" href="../images.php?id=' . $uno['id'] . '"><img src="'. $uno['thumbs'].'" border="0" /></a>';
    }
    
    0 讨论(0)
  • 2021-01-23 02:57

    The mysql_query returns a resource id, you should fetch an array:

    $results = mysql_query("select * from classpics");
    
    while($row = mysql_fetch_array($results)){
      echo '<td valign="middle" align="center"><a class="neutral" href="../images.php?id=' . $row['id'] . '"><img src="'. $row['thumbs'].'" border="0" /></a>';
    }
    
    0 讨论(0)
  • 2021-01-23 03:00

    you should fetch data from result

    while($data=mysql_fetch_array($results)) {
    echo '<td valign="middle" align="center"><a class="neutral" href="../images.php?id=' . $uno['id'] . '"><img src="'. $uno['thumbs'].'" border="0" /></a>';
    

    }

    0 讨论(0)
提交回复
热议问题