php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12770 ODBC and PHP help needed.. Advanced
Submitted: 2001-08-15 13:52 UTC Modified: 2001-08-18 18:04 UTC
From: webmaster at e-anmar dot com Assigned:
Status: Not a bug Package: ODBC related
PHP Version: 4.0.6 OS: win98 with PWS
Private report: No CVE-ID: None
 [2001-08-15 13:52 UTC] webmaster at e-anmar dot com
What i want to do is retrieve data from a table in access using odbc. I can retrieve info correctly, except from when i want to retrieve specific information.
I want to create a table on a webpage that retrieves a column of info, and uses this info to make a link. With this link there will be a querystring called id, and this comes from the ID field in my DB which i also have retrieved using my select statement.

So how do i use odbc_result and odbc_fetch_row together to achieve this. Or is there another method using ODBC that i dont have knowledge of.

Beneath is my code::

Thnx in advance


<HTML>
<HEAD>
<TITLE>MXManiaWorld :: Tracks - Download</TITLE>
<STYLE TYPE="text/css">
TH {color: white; background-color: gray}
TD {background-color: silver; text : black }
</STYLE>
</HEAD>
<BODY bgcolor="navy" text="">
<CENTER>

<?php
//retrieve data from DB and show in browser.
//Img, then at side details.

//Declare DB variables
$odbc_dsn = 'mxm_db';
$odbc_userid = '******';
$odbc_userpassword = '******';

//CONNECT to DB
if(!($odbc_db=odbc_connect("$odbc_dsn", "$odbc_userid", "$odbc_userpassword")))
die("Couldn't connect to odbc database - $odbc_dsn");


//---------------------------------------------------


echo "<TABLE WIDTH='98%' border='1' bordercolor='#ffffff'>";

$query2 = "SELECT ID, FileName FROM tbl_uploads";

//submit query
if(!($odbc_rs2 = odbc_exec($odbc_db, $query2)))
die("Error executing query. Please inform the webmaster");

?>

<TR><TH>ID</TH><TH>Trackname</TH></TR>

<?php

while($query_data = odbc_fetch_row($odbc_rs2)) {
$num_cols = odbc_num_fields($odbc_rs2);
for($a = 1; $a <= $num_cols; $a++) {

if(!($track_id = odbc_result($query2, $a)))
die("Couldn't get result");
if(!($tracks = odbc_result($query2, $a)))
die("Couldn't get result") ;
echo "<TR>";
echo "<TD>$track_id</TD>";
echo "<TD><a href='./tracks.php?id=" . $track_id . "'>" . $tracks . "</a>";
echo "</TD></TR>";
}

}

echo "</TABLE>"
?>

</CENTER>
</BODY>
</HTML>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-18 18:04 UTC] kalowsky@php.net
okay this isn't a help forum, this is for reporting bugs 
within the PHP system.  as this bug is a request for help, 
marking as bogus.  if you have questions on how to use php 
you may wish to ask the php-general or php-database lists, 
or even ask on irc channels dedicated to PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC