Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
PHP & mySql

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
Tomz



Joined: 19 Dec 2004
Posts: 66
Location: Osijek

PostPosted: 05.08.2005 17:17    Post subject: PHP & mySql Add user to your forum ignore list Reply with quote

Zelim nesto najjednostavnije da uz pomoc PHP-a iz baze podataka (Artikli) uzmem iz table (igracke) iz rowa(Naziv) igracku (medo)

Evo ne uspjesnog koda:

Code:
<html>
<body>

<?php

   // connect to the server
   if( mysql_connect( 'localhost', 'Bk', 'strmag90' ) )
      echo( "Connected to database.<br>\n" );
   else
      die( "Error! Could not connect to server: " . mysql_error() );

// select the database
   mysql_select_db('artikli')
   or die( "Error! Could not select the database: " . mysql_error() );

$result = mysql_query("SELECT * FROM `igracke`")

{
echo("$result");
}


?>

</body>
</html>
Back to top
View user's profile Send private message Send e-mail
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 05.08.2005 18:11    Post subject: Re: PHP & mySql Add user to your forum ignore list Reply with quote

Tomz wrote:
echo("$result");

uf, ouch, joj.

kao prvo, ako nešto hoćeš ispisati, dovoljno je samo
Code:
echo $foo;
bez fancy zagrada i navodnika

no, ne možeš ispisati $result varijablu jer ona je u svom pomalo nečitljivom obliku te je možeš čitati samo funkcijama mysql_fetch_row() i sličnima, koji vade redak po redak iz rezultata SQL upita te ga prevode u polja

dakle:
Code:
$result = mysql_query("SELECT * FROM igracke WHERE naziv='medo' ");
$row = mysql_fetch_row($result);

sada u varijabli $row imaš cijeli redak u običnom polju. Naravno, ako ne postoji igračka 'medo', vratit će se prazan result set i nećeš iz njega moći izvući nikakve retke
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Tomz



Joined: 19 Dec 2004
Posts: 66
Location: Osijek

PostPosted: 07.08.2005 10:15    Post subject: Add user to your forum ignore list Reply with quote

Thanks Wink
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group