Jump to content

While for array OOP


Guest

Recommended Posts

Hello,

I have a code

<?php
require_once('../class.dbops.php');
$newsClass = new dbops() or die('error');
$singleNews = $newsClass->getNewsById(413);



$allNews = $newsClass->getAllNews();
echo '<pre>';
print_r($allNews);
echo '</pre>';
while($allNews > 1000) 
{
$id = $allNews['id'];
$head = $allNews['headline'];
$text = $allNews['text'];
$author = $allNews['author'];
$date = $allNews['date'];
echo "<table width='1500' border='3'>
	<td width='300'><h4>{$text}</h4></td>
	<td width='300'><h4>{$head}</h4></td>
	<td width='300'><h4>von {$author} am {$date}</h4></td>
	<td width=300'><a href='update2.php?id=".$row["id"]."' target='_blank'>edit</a></td>
	<form action=news2.php method=post>
	<input type='hidden' name='hidden' value='".$row['id']."'>
	<td width='300'><input type='submit' name='delete' value='delete'</td>
	<form action=news2.php method=post>
	</form>
	</table>";
}

combined with this page

	function getAllNews() {
		$query = "SELECT * FROM news WHERE 1 ";	
		$rs = mysql_query($query);
		$news = array();
		while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) ) {
			$news[] = $row;
		}
		return $news;
	}

Well, I am pretty sure my array is working.

My problem is to give out the array in the table.

Could you help me please?

Link to comment
https://forums.phpfreaks.com/topic/280618-while-for-array-oop/
Share on other sites

Thats how printed array looks like

Array
(
    [0] => Array
        (
            [id] => 413
            [headline] => hi
            [author] => qwerty
            [text] => ytrewq
            [date] => 2013-07-25
        )

    [1] => Array
        (
            [id] => 414
            [headline] => lala
            [author] => alal
            [text] => ertzfdz
            [date] => 2013-07-25
        )

    [2] => Array
        (
            [id] => 415
            [headline] => zuiuzou
            [author] => ou
            [text] => iozuioui
            [date] => 2013-07-25
        )

    [3] => Array
        (
            [id] => 416
            [headline] => jhln
            [author] => m,nmg
            [text] => hjdfzrt
            [date] => 2013-07-25
        )

    [4] => Array
        (
            [id] => 423
            [headline] => adsf asdfasd f
            [author] => adf adsgdsfg f
            [text] => fghfgha sdfas fdsaas dfasdf asdf asdfdsaf sda
            [date] => 2013-07-26
        )

    [5] => Array
        (
            [id] => 424
            [headline] => erdfgsdf
            [author] => fsdgsdf
            [text] => regwer
            [date] => 2013-07-29
        )

)
Link to comment
https://forums.phpfreaks.com/topic/280618-while-for-array-oop/#findComment-1442563
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.