Problems with adding a link to one position in a 'foreach' loop, please help


Posted on 16th Feb 2014 07:03 pm by admin

Hello!

Iam pretty new to programming and I wanna create a table with users from an array. It works just fine but in one table row I wanna add a link to it so I can click on the username to edit it later. This is my code right now:

Did you know?Explore Trending and Topic pages for more stories like this.
Code: $keys = mysql_query("SELECT * FROM users", $connection);
confirm_query($keys);
$result = mysql_query("SELECT * FROM users", $connection);
if (!$result)
confirm_query($keys);

echo "<table id="usertable">";
echo "<tr id="usertablemain">";
$a = array_keys(mysql_fetch_assoc($keys));
foreach($a as $b) { echo "<td>" . $b . "</td>";}
echo "</tr>";
while ($rows = mysql_fetch_assoc($result))
{
echo "<tr>";
foreach ($rows as $row)
{

echo "<td>".$row."</a>"."</td>";
}
echo "</tr>";
}
echo "</tr>";
echo "</table>";

I tried to nest a IF statement but it always give in some way true and all positions in the table get a <a href> tag. The array contains a position called 'username' which is in the second row. Please help me out
No comments posted yet

Your Answer:

Login to answer
222 Like 35 Dislike
Previous forums Next forums
Other forums

Help with forum quoting?
Hi im working on a forum and I have alomost finished it but i want a user quote system like twitter

Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, ho

Business Health Check
Hello

I need to create an online business health check for a client it will be multiple choi

remove a ; from emails in textarea
Code: <?php

session_start();

$database_host = "localhost&qu

Check if another session of the page is running?
I want to keep people from opening multiple tabs, or sessions of my Facebook app. Is it possible to

preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin

Rss feed question
Hi

My blog and my website are different. Am i able to take my rss feed
from my blog and p

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

Local file browser with php
Halo..

So this is what i want to create. I have a folder that i share and it has many movies.

Extracting Long text from message class with parameters
Hi,

I would like to extract the long text from a message class. However, the long text ha

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash