Jump to content
  • 0

ооп проблема


vvsh
 Share

Question

доброе время суток.

есть класс db

в нем функции query, row

class db {
var $query_id;
function query($query) {
$this->query_id = mysql_query($query);
}
function row() {
return mysql_fetch_array($this->query_id);
}
}

когда в классе show я наследую класс db

и пишу функцию которая выводит информацию

class show extends db {
function data() {
$this->query("SELECT * FROM table");
$num = $this->num();
if($num>0) {
$i = 1;
while($row = $this->row()) {
$this->query("SELECT * FROM table2 WHERE field2 = '$row[field]'");
$nums = $this->num();
$body .= "<a href='$row[field3].html'>$row[field4] [$nums]</a>";
if($i!=$num){
$body .= "<br>";
}
$i++;
}
} else {
$body .= "Пусто";
}
return $body;
}
}

вызываю данную функцию так:

$show = new show;

$show->data();

В этой таблице около 20 записей.

При выводе, мне выводит только так

<a href='1.html'>1 [1]</a>

[0]

хотя должно вывести

<a href='1.html'>1 [1]</a>

<a href='2.html'>2 [2]</a>

<a href='3.html'>3 [3]</a>

и т.д.

как мне сделать так, чтобы выводило как надо?

Edited by vvsh
Link to comment
Share on other sites

  • Answers 51
  • Created
  • Last Reply

Top Posters For This Question

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • 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. See more about our Guidelines and Privacy Policy