Jump to content

calling data twice from an array


Ryoku

Recommended Posts

I don’t know enough about arrays to use this correctly so I think I should ask someone.

 

I have a problem with a news system I’m making, I have an array that the sql response give me and when I call them it gives me the data in the order the DB vomits.

 

Well my problem is that I want to create an edit button for a/the post but I need to do so based off the date, the root of the problem is that if I call the date again I will get the next date in the array not the date of the post I want to edit.

 

Essentially what I’m asking is how do I call the same data twice in the same loop?

 

Link to comment
https://forums.phpfreaks.com/topic/119764-calling-data-twice-from-an-array/
Share on other sites

wow, completely not how i thought it was going to react. i didn't even test it because i thought it was going to error.

 

... um it worked correctly when i called the value twice in the same loop

 

but for the sake of argument and example this is the snippet in question ^^;

$result = mysql_query("SELECT * FROM post ORDER BY date DESC LIMIT 5 OFFSET " . $offset);

while($row = mysql_fetch_array($result))
{
echo $row[date] . "<br> \n";
echo $row[subject] . "<br> \n";
echo $row[body] . "<br>\n";
echo "<hr>\n";
echo $row[date];
}
}

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.