Re: Newbie: Images refs not loading (Broken Icons) How to?
| From: | Steve Werby | Date: | Tue, 13 Feb 2001 03:41:58 +0000 |
| Subject: | Re: Newbie: Images refs not loading (Broken Icons) How to? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39321@lists.php.net to get a copy of this message | ||
"Malouin Design Graphique" <lists@malouin.qc.ca> wrote:
> Is there anything wrong with this code below?
> Any help or fix to this code would be very much appreciated.
Let's take a look.
> $db = mysql_connect("www.server.com", "root", "password");
> mysql_select_db("db_name", $db);
> $sql = "select * from table_name order by 'date'";
> $sql = "select * from table_name";
The second $sql overwrites the first so hopefully you didn't want the first.
> $result = mysql_query($sql);
> while ($row = mysql_fetch_array($result)) {
> print("<tr><td bgcolor=\"#003399\">");
> printf("<img src=\"$indice_url\">%s</td></tr>\n",
> $row["indice_url"]);
Where is $indice_url being set? You call it in printf() but it was not
previously set in your code. I think you just don't understand how to
properly use printf() and since you're not really using it to format a
string, like it's intended to be used I'm not going to bother to explain how
to use it. I have an idea what you're trying to do, but in my opinion
printf(%s, $var) is a horrible way to pull data from a query result so
instead of showing you how to fix it, I'll show you a better way. Why not
do something like:
$result = mysql_query( $sql );
while ( $row = mysql_fetch_array( $result ) )
{
echo "<tr><td><img
src=\"$row[indice_url]\">$row[indice]</td></tr>\n";
}
--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/