troubleshooting Question

Organising results from php query into suitable table and linking database info to an image or text.

Avatar of crojet
crojet asked on
PHP
16 Comments1 Solution283 ViewsLast Modified:
Hi

im after some help with sorting my results from a query to my mysql database. i would like to sort them into a table. I have started it but having trouble seperating some results into different areas.

The sort of thing im after would look like this:

Number: 1
First line: high street
Second line: new road
city: london
county: londonshire
post code: l45 8uh

where the second colum will be the information from the database, and the first just the headings.

i also have some inputs from tick boxes into my database which result in the tick being represented in the database by words. Is there a way in which when it comes back from a query result it isnt in the form of the word but an image, maybe a tick or a cross so it would read

water: x or
water: 

thanks

chris
if(mysql_num_rows($result)==0)
  echo "<p>There are no reviews for that accommodation.</p>\n";
else {
	// Table header.
	//echo '<table>
		//<tr><td><b>Number</b></td></tr>
		//<tr><td align="left"><br><b>First Line</b></td></tr>
		//<tr><td align="left"><b>Second Line</b></td></tr>';
	
	// Fetch and print all the records.
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
		echo '<table>
 
			<p><b>Address</b></p>
			<tr><td><b>Number:</b></td><td>' . $row['number'] . '</td></tr>
			<tr><td><b>First Line:</b></td><td>' . $row['firstline'] . '</td></tr>
			<tr><td><b>Second Line:</b></td><td>' . $row['secondline'] . '</td></tr> 
			<tr><td><b>City:</b></td><td>' . $row['city'] . '</td></tr>
			<tr><td><b>County:</b></td><td>' . $row['county'] . '</td></tr>
			<tr><td><b>Post Code:</b></td><td>' . $row['postcode'] . '</td></tr>
 
			
			<tr><td><b>Water:</b></td><td>' . $row['water'] . '</td></tr>
			<tr><td><b>Gas:</b></td><td>' . $row['gas'] . '</td></tr>
			<tr><td><b>Electric:</b></td><td>' . $row['electric'] . '</td></tr> 
			<tr><td><b>Internet:</b></td><td>' . $row['internet'] . '</td></tr>
			<tr><td><b>Sky/Cable:</b></td><td>' . $row['skycable'] . '</td></tr>
			<tr><td><b>Cleaning:</b></td><td>' . $row['cleaning'] . '</td></tr>
 
 
 
			';
	}
 
	echo '</table>';
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros