473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Php class question..?

i want My database in all link_id data print screen. my database link_id's 10,22,30,40,45

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. class VeriCek{
  3.     public $dbhost = 'localhost';
  4.     public $dbuser = 'root';
  5.     public $dbpass = '1';
  6.     public $dbname = 'linkekle';
  7.     public function BaglanDB(){
  8.     if( $link ){
  9.         return $link;
  10.     }
  11.  
  12.     $link = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpass) or die('Sunucuya Bağlanamadı.' );
  13.     mysql_select_db($this->dbname, $link) or die('Sunucuya Bağlanamadı.');
  14.     mysql_query("SET NAMES UTF8");
  15.     return $link;
  16.     }
  17.  
  18.     public function cekhepsi(){
  19.     $sql = "select * from linkler";    
  20.     $query = mysql_query($sql,$this->BaglanDB());
  21.     while ($rs=mysql_fetch_assoc($query)){
  22.     return $rs["link_id"];
  23.     }
  24.     }
  25. }
  26.  
  27. $deneme = new VeriCek();
  28. echo $deneme->cekhepsi();
  29.  
  30. ?>
this line "return $rs["link_id"];" return the "10" database in the only first.
i want all link_id print screen..
please help me. :)
Dec 3 '10 #1

✓ answered by Dormilich

then you must call return after finishing the while() loop.
Expand|Select|Wrap|Line Numbers
  1. $id = "";
  2. while ($rs=mysql_fetch_assoc($query)){
  3. $id .= $rs["link_id"];
  4. }
  5. return $id;

3 1361
Dormilich
8,658 Expert Mod 8TB
then you must call return after finishing the while() loop.
Expand|Select|Wrap|Line Numbers
  1. $id = "";
  2. while ($rs=mysql_fetch_assoc($query)){
  3. $id .= $rs["link_id"];
  4. }
  5. return $id;
Dec 4 '10 #2
Thank you very much.. :)
Dec 4 '10 #3
Samishii23
246 100+
May I make a suggestion?
When you make a class, any variables or functions that are for "in-Class" only, set to private.
Dec 4 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tim Hill | last post by:
I'm just getting up to speed on Java, and have a question about local class behavior. Here's a mini-app to illustrate: interface Foo { void print(); } class LocalClassTest { public static...
2
by: Charles Keepax | last post by:
Sorry about the newbie question. If a class contains a pointer to some data, and memory is allocated to that pointer in the constructor. Naturally the destructor should free that memory, right? So...
1
by: Jean Pion | last post by:
Dear readers, Can I have a class selector the pseudoclasses like: .menuw { general_stuff_for_this_class; } a.menuw:link { special_for_link;} a.menuw:visited {special_for_visited; }...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
6
by: mrmagoo | last post by:
I have a class that accepts String and Long datatypes. Class Menu Private FirstTier as String Private SecondTier as Long Sub New(ByVal FirstTier As String, _ ByVal SecondTier As Long) ....
7
by: Brian C | last post by:
Hello all, I have, what I'm sure is an idiotic question, but I can't seem to find an answer for it (probably looking in the wrong direction of course). I'm coming from numerous years in C...
6
by: Xemnosyst | last post by:
Hello. I have an obscure question for y'all. Consider an inner class: class Outer1 { class Inner1 { } } Now in a different inner class I extend the first one. Does anyone know...
1
by: sittner | last post by:
Hello there, i am pretty new to object-oriented programming and i have a question: let's say i have a simple class such as: class father: age=... name=.... def abcd..... class son(father):...
5
by: Amal P | last post by:
Dears, I have a question. class Data { }; class DisableDerive:virtual protected Data // A base class { private:
4
by: t f | last post by:
hi just a quick question - i have the something like the following public abstract class ClassA { protected int iA; public int Value { get {return iA;} set { iA = value;}}
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.