Retriving Information From My SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iimrii
Forum Newbie
Posts: 3
Joined: Wed May 14, 2003 1:54 pm

Retriving Information From My SQL

Post by iimrii »

Ok in my database there is a table called "say" in that table there are 2 fields one is "player name" and the second is "say"

I modified a code but it is not really enough the fallowing code just lists the "say" field so the out come is like this

sddjska

dsadsadsa

dsadsad

on the web page and here is the code

Code: Select all

<html>
<head>
<title> Log Say </title>
<head>
<body>
<?php
  // Connect to the database server
  $dbcnx = @mysql_connect("localhost", "boyem", "pass", "boyem_com");
  if (!$dbcnx) &#123;
    echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
    exit();
  &#125;
  
  if (! @mysql_select_db("boyem_com") ) &#123;
    echo( "<p>Unable to locate Log Say " .
"database at this time.</p>" );
    exit();
  &#125;
?>
<p> Log Say: </p>
<blockquote>
<?php

   // 
  $result = @mysql_query("SELECT say FROM say");
  if (!$result) &#123;
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
  &#125;
  // 
  while ( $row = mysql_fetch_array($result) ) &#123;
    echo("<p>" . $row&#1111;"say"] . "</p>");
  &#125;
?>
</blockquote>
</body>
</html>
outcome is here http://www.boyem.com/deneme.php

well as you can see it just lists the says but I want it to be shown like this

player_name: Say

Player_name: say

player_name: say


well of course player_name changes according to what is in the rows.

how can i do that...I am really new to PHP

thanks a lot in advance
Last edited by iimrii on Wed May 14, 2003 2:07 pm, edited 1 time in total.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try:

Code: Select all

while ( $row = mysql_fetch_array($result) ) { 
    echo '<p>Player Name: ' . $row["say"] . '</p>'; 
}
Mac
iimrii
Forum Newbie
Posts: 3
Joined: Wed May 14, 2003 1:54 pm

Post by iimrii »

twigletmac wrote:Try:

Code: Select all

while ( $row = mysql_fetch_array($result) ) { 
    echo '<p>Player Name: ' . $row["say"] . '</p>'; 
}
Mac
it wont work it is just gonna wirte Player Name and than say

the table in the database lists like this

player name-----------------------say

momo-------------------------------helloo
devil---------------------------------sup

well in your case it will just write Player Name and dump the says row by row...am I clear??
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Now it makes more sense. Where does the players name come from? Is it also stored in the say table?

Mac
iimrii
Forum Newbie
Posts: 3
Joined: Wed May 14, 2003 1:54 pm

Post by iimrii »

some one in another forum helped me out

for future referance here it is

Code: Select all

$result = @mysql_query("SELECT player_name, say FROM say"); 
if (!$result) &#123; 
echo("<p>Error performing query: " . mysql_error() . "</p>"); 
exit(); 
&#125; 
// 
while ( $row = mysql_fetch_array($result) ) &#123; 
echo("<p>" . $row&#1111;'player_name'] . " :: " . $row&#1111;"say"] . "</p>"); 
&#125;
Post Reply