Solved

How to use data from my table in mysql

Posted on 2013-06-11
3
164 Views
Last Modified: 2013-06-11
Hi!

Have this webpage:

<?php // RAY_EE_login.php
require_once('RAY_EE_config.php');
$table1 = 'Kontroller';
// ACCESS TO THIS PAGE IS TESTED BUT NOT CONTROLLED
if ($uid = access_control(TRUE))
{

}
else
{
        header("location: login.php");
	    exit;
}

?>
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>Test system</title>

</head>

<body>
<link rel="stylesheet" href="default.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<Form method="post" action="side3.php">
<table summary="Services, or Links box template" class="servicesT" cellspacing="1">
<tr><td colspan="2" class="servHd">Min Test</td></tr>


<tr>
	<td class="servBodL_medborder" >HERE I WANT DATA FROM MYSQL TABLE</td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>

</table>
</Form>
<br>
<table summary="Services, or Links box template" class="servicesT" cellspacing="0">
<tr><td colspan="2" class="servHd">MY OPEN</td></tr>
<tr>
	<td class="TESTE" width="92%">TEST</td>
	<td class="servBodL_medborder" width="8%"><input type="submit" id="GULKN" value=">"></td>
</tr>
</table>
<br><br>
<Form method="post" action="logut.php">
<fieldset id="actions">
	<input type="submit" id="LOGIN" value="Logg ut">
</fieldset>
</Form>

</body>
</html>

Open in new window


I need to pu this Php code in this block (code abow)
<tr>
	<td class="servBodL_medborder" >HERE I WANT DATA FROM MYSQL TABLE</td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>

Open in new window


<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)){
    $navn = $row3['Navn'];
	echo $navn;
}

?>

Open in new window


How do i do this ?
0
Comment
Question by:team2005
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39237559
<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)){
    $navn = $row3['Navn'];
?>
<tr>
	<td class="servBodL_medborder" ><?php echo $navn; ?></td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>
<?php
}

?>

Open in new window

0
 
LVL 55

Expert Comment

by:Julian Hansen
ID: 39237567
Or
<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)) :
?>
<tr>
	<td class="servBodL_medborder" ><?php echo  $row3['Navn']; ?></td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>
<?php
endwhile;
?>

Open in new window

using while() : endwhile; is sometimes preferable to using {} when mixing code with html output as it easily enables you to see where code blocks start and end.
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 39237593
Exelent :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question