Hello Alistair,

Wednesday, March 10, 2004, 10:26:03 PM, you wrote:

AH> dim Type
AH> Type = CStr(Request.QueryString("action")) (getting parameter from URL)

unset($type);
$type = $_GET['action'];

(Please note - you don't HAVE to "unset" each variable, but if you are
working in a Register Globals ON environment, it's a good safety
measure).

AH> strDBPath = Server.MapPath("/_database/database.mdb")

MySQL doesn't work the same way as MDB files (thank goodness), so you
need to create a connection to the MySQL database:

$link = mysql_connect('localhost', 'username', 'password');

AH> Set cnn = Server.CreateObject("ADODB.Connection")
AH> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

mysql_select_db('database_name', $link);

AH> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
AH> order by style")

$sql= "SELECT * FROM table WHERE type='$type' ORDER BY style";
$result = mysql_query($sql);

You now have the entire "record set" in $result. To obtain the first
row of data, do this:

AH> <%Do While Not rstSimple.EOF%>
AH> do something
AH> <%
AH> rstSimple.MoveNext
AH> Loop

A few ways to do this:

$total_records = mysql_num_rows($result);

for ($i=0; $i < $total_records; $i++)
{
    $data = mysql_fetch_assoc($result);
    print_r($data);
}

$data will now be an array holding the first set of information. The
print_r line just displays it so you can see it easily.

Instead of a FOR loop you could do a "while" loop checking to see the
end of the $result set, i.e.:

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
      // do stuff
      print_r($row);
}

AH> <%=rst.fields("whatever").value%>

<?=$data['whatever']?>

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to