View previous topic :: View next topic |
Author |
Message |
croatius
![](images/avatars/52169949747542d848143b.jpg)
Joined: 02 Oct 2007 Posts: 34 Location: pumpaona
|
Posted: 02.10.2007 14:18 Post subject: PHP skripta ispisuje samo jedno polje umjesto 25? |
|
|
Jeli mi moze netko reci gdje sam pogrijesio?
http://pastebin.com/m540e4d72 source |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
jojo
![](images/avatars/17878545254385c0992bf42.gif)
Joined: 27 Jan 2005 Posts: 1591 Location: insula aurea
|
Posted: 02.10.2007 14:31 Post subject: |
|
|
nisam odavno radila s php-om al onako odokativno čini mi se ko da nema petlje... al ne uzimaj me baš zaozbiljno |
_________________ deviant / malomorgen / videoholik / cimer fraj |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
zytzagoo mi3.crew
![](images/avatars/298588548884561e5609.gif)
Joined: 25 Aug 2003 Posts: 1842 Location: Zagreb, Hrvatska
|
Posted: 02.10.2007 14:38 Post subject: |
|
|
da, nema petlje.
postao sam na pastebin correction, ali evo ga i ovdje za kasnije:
Code: | <?php
include("cms-header.php");
$connector = new dbConnect();
$result = $connector->query('SELECT * FROM `articles` ORDER BY `article-date` DESC LIMIT 25');
?>
<tr>
<td> Dobro dosao, <? echo $_SERVER['REMOTE_ADDR']; ?>!</td>
</tr>
<tr>
<td> Danas je <?php echo date("d.M Y") . " i "; echo date("G:i"); ?> sati. </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> » Zadnji clanci: <br>
<?php
while ($row = $connector->fetchArray($result)) {
echo $row['article-title'] . " - " . $row['article-date'] . "<br>"; ?>
}
?>
</td>
</tr>
</table
<? include("cms-footer.php"); ?> |
|
_________________ [+]I[+]am[+]my[+]own[+]religion[+] |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Tristan
![](images/avatars/131157980646129c2623a78.gif)
Joined: 01 Aug 2006 Posts: 614 Location: Under the sky
|
Posted: 02.10.2007 14:38 Post subject: |
|
|
Nema petlje da...
Prvo, odakle taj klasa dbConnect, to neka tvoja ili? tražio sam na php.net, nisam našao...
No ok, recimo da $row = $connector->fetchArray($result); pohvata sve rezultate iz baze...
Znači imaš array, sa petljom foreach napraviš slijedeće:
Code: | foreach($row as $data)
{
/* ako želiš ispisat neku varijablu napraviš to sa echo $data[/*polje koje hoćeš ispisat, datum, text, što već trebaš*/];
}
|
Nadam se da bude od pomoći |
_________________ Carpe diem... |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Tristan
![](images/avatars/131157980646129c2623a78.gif)
Joined: 01 Aug 2006 Posts: 614 Location: Under the sky
|
Posted: 02.10.2007 14:39 Post subject: |
|
|
evo zytzagoo već postao u međuvremenu... može i delete... |
_________________ Carpe diem... |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
croatius
![](images/avatars/52169949747542d848143b.jpg)
Joined: 02 Oct 2007 Posts: 34 Location: pumpaona
|
Posted: 02.10.2007 15:10 Post subject: |
|
|
Tristan wrote: | Nema petlje da...
Prvo, odakle taj klasa dbConnect, to neka tvoja ili? tražio sam na php.net, nisam našao...
No ok, recimo da $row = $connector->fetchArray($result); pohvata sve rezultate iz baze...
Znači imaš array, sa petljom foreach napraviš slijedeće:
Code: | foreach($row as $data)
{
/* ako želiš ispisat neku varijablu napraviš to sa echo $data[/*polje koje hoćeš ispisat, datum, text, što već trebaš*/];
}
|
Nadam se da bude od pomoći |
Sredio sam to, dbConnect je funkcija. Hvala svima |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
PaNtHeR
![](images/avatars/38078130748f70a0debbfd.gif)
Joined: 17 Sep 2003 Posts: 161
|
Posted: 03.10.2007 19:35 Post subject: |
|
|
Quote: | Sredio sam to, dbConnect je funkcija. Hvala svima |
dbConnect je klasa ![Wink](images/smiles/icon_wink.gif) |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Tristan
![](images/avatars/131157980646129c2623a78.gif)
Joined: 01 Aug 2006 Posts: 614 Location: Under the sky
|
Posted: 03.10.2007 19:55 Post subject: |
|
|
PaNtHeR wrote: | Quote: | Sredio sam to, dbConnect je funkcija. Hvala svima |
dbConnect je klasa ![Wink](images/smiles/icon_wink.gif) |
da, baš to i gledam, al nisam htio postat bzvz radi toga... ček, jel to php built-in klasa ili?
našao sam samo funkciju db2_connect |
_________________ Carpe diem... |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
PaNtHeR
![](images/avatars/38078130748f70a0debbfd.gif)
Joined: 17 Sep 2003 Posts: 161
|
Posted: 04.10.2007 12:41 Post subject: |
|
|
ne vjerujem da je built-in, nije niti bitno, bitno da se spaja ![Cool](images/smiles/icon_cool.gif) |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
croatius
![](images/avatars/52169949747542d848143b.jpg)
Joined: 02 Oct 2007 Posts: 34 Location: pumpaona
|
Posted: 06.10.2007 19:19 Post subject: |
|
|
Tristan wrote: | PaNtHeR wrote: | Quote: | Sredio sam to, dbConnect je funkcija. Hvala svima |
dbConnect je klasa ![Wink](images/smiles/icon_wink.gif) |
da, baš to i gledam, al nisam htio postat bzvz radi toga... ček, jel to php built-in klasa ili?
našao sam samo funkciju db2_connect |
nije built-in, sam sam je definirao, btw u mom slucaju je dbConnect i klasa i funkcija.. |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|