Solved

How to use data from my table in mysql

Posted on 2013-06-11
3
163 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 54

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 54

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

777 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