Jump to content

Serious help need displaying rows


pumpylumpy

Recommended Posts

hello, my name is Andy, and i am new here and i would very much like some help with a problem i have no idea how to solve, i have been looking for hours with no luck, pulling my hair out to try and work out how it can be done. heres the problem.

 

i connect to my database of Flats and i want to display each property in a table showing there bed, window type, etc etc.

 

i know i have to make query's to the database and store them in variables and put them in the html table but i cant find an example,

 

here is what i want the table to look like


<td>
<table width="930" border="0" cellspacing="0" cellpadding="0" align="center" class="text">
  <td valign="top">
<table width="930" class="text" cellpadding="5">
<tr>
  <td width="70">Property</td>
  <td width="391">Feild Property here</td>
<td width="429" rowspan="8">Images will be added manul here</td>
</tr>
<tr>
  <td>Nature</td>
  <td>Feild Flat Here</td>
</tr>
<tr>
  <td>Beds</td>
  <td>Feild Beds Here</td>
</tr>
<tr>
  <td>Floor</td>
  <td>Feild Floor here</td>
</tr>
<tr>
  <td>Heating</td>
  <td>Feild Heating Here</td>
</tr>
<tr>
  <td>Windows</td>
  <td>Feild Windows Here</td>
</tr>
<tr>
  <td>Other</td>
  <td>Feild Other Here</td>
</tr>
<tr>
  <td>Tyical Rent</td>
  <td>Feild Rent here</td>
</tr>
</table>
</td></tr></table>
</td>
</tr>

can someone please help me with this or i will fail uni :( no pressure lol

 

thanks in advanced

 

andy

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/235339-serious-help-need-displaying-rows/
Share on other sites

heres an example of how to pull values out of a db and display them.

$sql = "SELECT * FROM table_name"; //this retrieves all info from given table
$query = mysql_query($sql); //this tells mysql to make a query
$row = $mysql_fetch_assoc($sql); //this assigns the variable $row to an array of you database values
$row['column_name']; //this draws out the value of whatever your column name is
$column_name = $row['column_name'];// this assigns the column name to a var
echo $column_name; //echo column name

i get this

Fatal error: Function name must be a string in /home/robslade/public_html/flats.php on line 34

 

 

this is the code i used (minus my password and username)

<?php 
$database="robslade_luckystar"; 
mysql_connect ("localhost", "********", "******"); 
@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM Flats"; //this retrieves all info from given table
$query = mysql_query($sql); //this tells mysql to make a query
$row = $mysql_fetch_assoc($sql); //this assigns the variable $row to an array of you database values
$row['Property']; //this draws out the value of whatever your column name is
$column_name = $row['Property'];// this assigns the column name to a var
echo $column_name; //echo column name
?>

 

 

i want to cry

 

ok, so i found some code that is going to help me get a little bit further but my result is the hole columns of data where i want just one,

<?php
$con = mysql_connect("localhost", "************", "************");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("robslade_luckystar", $con);

$result = mysql_query("SELECT * FROM Flats");

echo "<table border='1'>
<tr>
<th>Property</th>
<th>Nature</th>
<th>Beds</th>
<th>Floor</th>
<th>Heating</th>
<th>Windows</th>
<th>Other</th>
<th>Rent</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Property'] . "</td>";
  echo "<td>" . $row['Nature'] . "</td>";
  echo "<td>" . $row['Beds'] . "</td>";
  echo "<td>" . $row['Floor'] . "</td>";
  echo "<td>" . $row['Heating'] . "</td>";
  echo "<td>" . $row['Windows'] . "</td>";
  echo "<td>" . $row['Other'] . "</td>";
  echo "<td>" . $row['Rent'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

so i can have a table for each propertie

 

 

heres the link

 

http://207.58.171.181/~robslade/flats.php

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.