FirePhoenix Posted February 26, 2007 Share Posted February 26, 2007 So I posted a thread erly er about how to pull info from table and I got it..kind of here is my code <?php include ("config.php"); mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect"); @mysql_select_db($dbname) or die ("Unable to select database"); $query="SELECT * FROM mainone"; $result=mysql_query($query); $num=mysql_numrows($result); $greeting=mysql_result($result,"greeting"); $imageone=mysql_result($result,"imageone"); $imagetwo=mysql_result($result,"imagetwo"); mysql_close(mysql_connect($dbhost,$dbuser,$dbpass)); ?> Now in the table I just want to pull from the one and only row its values are as follows id= 1, greeting= sometext, and imageone and two are http:// links(text) now I know my out put variables are right and I think the problem is with how I am getting the info from the table. Can someone please help?? Quote Link to comment Share on other sites More sharing options...
btherl Posted February 26, 2007 Share Posted February 26, 2007 What output are you expecting and what are you seeing? Quote Link to comment Share on other sites More sharing options...
FirePhoenix Posted February 26, 2007 Author Share Posted February 26, 2007 oh sorry.... I am wanting the values of the columns in three different variables but I get a "1" in all three which is the id for the row Quote Link to comment Share on other sites More sharing options...
btherl Posted February 26, 2007 Share Posted February 26, 2007 I think it's the arguments to mysql_result().. http://sg.php.net/manual/en/function.mysql-result.php Try mysql_result($result, 0, "greeting") to fetch the greeting column from row 0. To display all rows (if you're expecting more than one), you'll need a loop. Usually I do this: while ($row = mysql_fetch_assoc($result)) { $greeting = $row['greeting']; $imagone = $row['imageone']; $imagetwo = $row['imagetwo']; # Do something with the data here } Quote Link to comment Share on other sites More sharing options...
FirePhoenix Posted February 26, 2007 Author Share Posted February 26, 2007 thank you very much i give it a try Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.