Originally posted by tsinka
Hi,
can you post some more code ? Do you get any error messages ?
Hi,
So this is the code I use together which Access which works:
<?
$conn_id=odbc_connect("Forum","","");
$sql="SELECT * FROM forum WHERE forum.Pid = 0 ORDER BY datum DESC ";
$result=odbc_exec($conn_id,$sql);
?>
<a href="nytt.php">
<p><font size="2" face="Arial">New message</a></p>
<table border="0" cellpadding="3">
<tr>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Topic</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Name</font></th>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Email</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Date</font></th>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Number of answers:</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Latest message:</font></th>
</tr>
<?
while(odbc_fetch_row($result)){
?>
<tr>
<td BGCOLOR="#CCCCCC"><a href="las.php?iid=<?=odbc_result($result,"iid")?>"><font size="2" face="Arial"><?=odbc_result($result,"topic")?></a>
<br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=odbc_result($result,"Name")?><br>
</font></td>
<td BGCOLOR="#CCCCCC"><font size="1" face="Arial"><?=odbc_result($result,"Email")?><br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=odbc_result($result,"Date")?><br>
</font></td>
<td BGCOLOR="#CCCCCC"><font size="1" face="Arial"><?=odbc_result($result,"Number")?><br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=odbc_result($result,"latest")?><br>
</font></td>
</tr>
<? }
?>
</table>
</body>
</html>
The posts generated by the sql question is collected in $result. Then I write a table with headlines Topic, Name etc etc. With "while etc " I loop the posts from $result into the fields in the table. Works just fine with Access
I put a lot of effort in this, since I am quite a newbie. Unfortunately my server provider does not support MS, only MySQL so I had to go on trying to "translate" the odbc commands and this is where I fail.
The attempt looks like this. (I have kept the Swedish words here - hope it is not too confusing - in the table on the php page and in the MySQL table. I have tried to write "sql" in $result both as sql and "sql" but this has not affected the malfunctioning of my code.
<?
$lank=mysql_connect("localhost","","");
$sql="SELECT * FROM forum WHERE forum.pid = 0 ORDER BY datum DESC ";
$result=mysql_db_query("tornsdb",""sql"");
?>
<a href="testnytt.php">
<p><font size="2" face="Arial">Nytt inlägg</a></p>
<table border="0" cellpadding="3">
<tr>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Ämne</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Namn</font></th>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Epost</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Datum</font></th>
<th BGCOLOR="#CCCCCC"><font size="1" face="Arial">Antal svar:</font></th>
<th BGCOLOR="#99CCFF"><font size="1" face="Arial">Senaste inlägg:</font></th>
</tr>
<?
while($rad=mysql_fetch_array($result)){
?>
<tr>
<td BGCOLOR="#CCCCCC"><a href="testlas.php?iid=<?=$rad["IID"]?>"><font size="2" face="Arial"><?=$rad["Amne"]?></a>
<br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=$rad["Namn"]?><br>
</font></td>
<td BGCOLOR="#CCCCCC"><font size="1" face="Arial"><?=$rad["Epost"]?><br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=$rad["datum"]?><br>
</font></td>
<td BGCOLOR="#CCCCCC"><font size="1" face="Arial"><?=$rad["Antal"]?><br>
</font></td>
<td BGCOLOR="#99CCFF"><font size="1" face="Arial"><?=$rad["senaste"]?><br>
</font></td>
</tr>
<? }
?>
</table>
</body>
</html>
/Gunnar