MySQL Forums
Forum List  »  PHP

Re: php w/mysql backend. Getting a layout to work with the db selected info
Posted by: Bob Field
Date: May 07, 2006 04:07PM

Maybe this will help:

<?php
mysql_connect("server", "user", "password") or die ("Connect failed " . mysql_error());
$query = "SELECT something FROM yourdatabase";
$result = mysql_query($query) or die ("Invalid query: " . mysql_error() . " Whole query: " . $query);
$row = mysql_fetch_assoc($result)
if (!$row) die ("No results returned");
?>

At this point you have $row which is an array of values for the columns of the resultset from your query. Note this is only the first row of the resultset, if there are more rows you'll need to loop and call mysql_fetch_assoc() again.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.