473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Webpage not displaying records

I am very new with PHP...started doing this a few days ago to help someone and I need some help please. I have a webpage that is not displaying the records I want it to. The sql is correct, and I think the php code is correct to display the result, but php just "seems" to echo the php code that I have embedded in the page (maybe a type that I have missed). No errors seem to be happening, but it just does not display any records. Can anyone help please?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" >
  3. <head>
  4.     <title>C&J`s Lawn Service</title>
  5.     <link href="main.css" rel="stylesheet" type="text/css" />
  6. </head>
  7. <body>
  8.     <div id="wrapper">
  9.         <div id="branding">
  10.             <img src="images/branding2.gif" alt="C&J's Lawn Care" />
  11.         </div>
  12.         <div id="navigation">
  13.             <ul>
  14.                 <li class="first"><a href="index.html">Home</a></li>
  15.                 <li><a href="enterjob.html">Enter Job</a></li>
  16.                 <li><a href="services.html">Services</a></li>
  17.                 <li><a href="contactus.html">Contact Us</a></li>
  18.             </ul>
  19.         </div>
  20.         <div id="body">
  21.             <p> All Jobs: </p>
  22.             <blockquote>
  23. <?php
  24. error_reporting(E_ALL);
  25. ini_set('display_errors', True);
  26.  
  27.     $host="localhost"; // Host name 
  28.     $username="test"; // Mysql username 
  29.     $password="test12"; // Mysql password 
  30.     $db_name="testdb"; // Database name 
  31.     $tbl_name="jobs"; // Table name 
  32.  
  33.     // Connect to server and select databse.
  34.     mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  35.     mysql_select_db("$db_name")or die("cannot select DB");
  36.  
  37.     // Request the text of all the jobs
  38.     //$result=mysql_query("SELECT jobtype, jobdescription, phone FROM jobs j Join members m on m.id = j.userid Order By id desc");
  39.  
  40. $result=mysql_query("SELECT jobtype, jobdescription, phone FROM jobs j Join members m on m.id = j.userid Order By id desc", $link_id) or die('<hr />MySQL Error: ' .mysql_error(). '<hr />');
  41.  
  42.   // Display the text of each job in a paragraph
  43.   while ( $row = mysql_fetch_array($result) ) 
  44.   {
  45.     echo("<p>Job: " . $row['jobtype'] . "</p>");
  46.     echo("<p>Description: " . $row['jobdescription'] . "</p>");
  47.     echo("<p>Phone: " . $row['phone'] . "</p>");
  48.     echo("<br />";
  49.     echo("<br />";
  50.   }
  51. ?>
  52.             </blockquote>
  53.       </div>
  54. </body>
  55. </html>
  56.  
  57.  
Oct 4 '07 #1
3 1506
Atli
5,058 Expert 4TB
Hi Mike. Welcome to The Scripts!

Is the PHP code just being displayed in the page like any other text?
If that is so, is it possible that the file is not a .php file? A normal .html file will not execute the PHP code, but treat it as text and display it.

Also, in your mysql_query() function, you use a variable called '$link_id' as a second parameter. I can't find this variable anywhere before that. Try removing it and see what happens.
Oct 4 '07 #2
That was it...thank you very much. I did not realize that the page had to have a php extension. Course, now that you pointed it out, it makes sense :)
Oct 4 '07 #3
Atli
5,058 Expert 4TB
I'm glad you got it working :)
Don't hesitate to post again if you have any more questions or problems we can help with.
Oct 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim Graichen | last post by:
Good morning, I have a sub-form that displays records from a table as a continuous form. The table has several hundred records, but the subform only displays five or six records. The records do...
6
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
2
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that...
10
by: Johan Christensson | last post by:
Hi. Is there any other ways of displaying a webpage in an VB.Net form other then using the "Microsoft Web Browser" object? Any third-party? /Johan Ch
3
by: liberatingathena | last post by:
I'm writing you from Alajuela, Costa Rica. It's 4:30 in the morning here and I'm reaching a point of pure desperation as I've been searching the internet all night for a solution. I am not an...
1
by: sureshreddy | last post by:
hi friends, I want the time to be displayed for a webpage to redirect to another webpage. You can see this concept in job sites when we fill all the details and click the search button it displays...
1
by: sushant2009 | last post by:
Hi , I want to display empty databae table(actually table contains lot of records) to datagrid using dataset and dataadpter. After displaying i will fill new records in datagrid and i will save...
5
by: sejal17 | last post by:
hello everyone, I have a problem with displaying records between two dates.Below is my designing page: start date: combobox of month(smonth) & combobox of year(syear) end date :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.