Jump to content

Output


FirePhoenix

Recommended Posts

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??

Link to comment
https://forums.phpfreaks.com/topic/40109-output/
Share on other sites

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
}

Link to comment
https://forums.phpfreaks.com/topic/40109-output/#findComment-194092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.