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
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];
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

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