url from db
Posted: Mon Aug 18, 2003 4:12 pm
the code:
<?php
$db_name = "DBMedici";
$table_name = "specialita";
$connect = @mysql_connect("localhost", "root", "") or die("connect che????");
$select_db = @mysql_select_db($db_name, $connect) or die("cannot select db");
$sql = "
select specialita, url from $table_name order by specialita
";
$result = @mysql_query($sql, $connect) or die("non riesco a fare query");
echo "<tr class=`GridHeader`>
<th>specialita</th>
</tr>
";
while ($riga = mysql_fetch_array($result)) {
echo "<tr class=\"GridRow\"
onmouseover=\"this.className='GridMOverRow'\"
onmouseout=\"this.className='GridRow'\" id=\"ggg\">";
echo "<td><a href='$url'>" .$riga['specialita']."</a></td>";
$url .= $riga['url'];
;
echo "</tr>";
//}
}
?>
well, the pint is to get the right url for every data. consider the db is like this:
mysql> explain specialita;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| Specialita | varchar(100) | | | | |
| url | varchar(100) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
but now, with this code i get the url composed with all records like that.
how should i fix it??
tnx, pacho
<?php
$db_name = "DBMedici";
$table_name = "specialita";
$connect = @mysql_connect("localhost", "root", "") or die("connect che????");
$select_db = @mysql_select_db($db_name, $connect) or die("cannot select db");
$sql = "
select specialita, url from $table_name order by specialita
";
$result = @mysql_query($sql, $connect) or die("non riesco a fare query");
echo "<tr class=`GridHeader`>
<th>specialita</th>
</tr>
";
while ($riga = mysql_fetch_array($result)) {
echo "<tr class=\"GridRow\"
onmouseover=\"this.className='GridMOverRow'\"
onmouseout=\"this.className='GridRow'\" id=\"ggg\">";
echo "<td><a href='$url'>" .$riga['specialita']."</a></td>";
$url .= $riga['url'];
;
echo "</tr>";
//}
}
?>
well, the pint is to get the right url for every data. consider the db is like this:
mysql> explain specialita;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| Specialita | varchar(100) | | | | |
| url | varchar(100) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
but now, with this code i get the url composed with all records like that.
how should i fix it??
tnx, pacho