| | |
Displaying PHP result within HTML?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I've searched through the forum, but I couldn't find an answer. How do you display a result within HTML?
Such as:
Thanks in advance.
Such as:
php Syntax (Toggle Plain Text)
$query = "SELECT * FROM customers WHERE job_number='$jobnumber'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ echo $row['first_name']; echo $row['last_name'];
Thanks in advance.
Last edited by peter_budo; Apr 5th, 2008 at 1:28 pm. Reason: [icode] is for one line of code, [code] is for multiple lines
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I want to display the ['first_name'], ['last_name'], ['email'] fields. Here's the script I have used to call up a result from my database, and the result is the
Did I help clear it a little? Thanks for your help...
echo $row['first_name'] , etc. I'm just trying to figure out how to wrap the result within HTML. php Syntax (Toggle Plain Text)
if(isset($_POST['submit'])) { $jobnumber=$_POST['jobnumber']; //connect $query = "SELECT * FROM customers WHERE job_number='$jobnumber'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ echo $row['first_name']; echo $row['last_name']; echo $row['email']; //etc... } } ?>
Did I help clear it a little? Thanks for your help...
Last edited by peter_budo; Apr 5th, 2008 at 1:28 pm. Reason: [icode] is for one line of code, [code] is for multiple lines
there's no problem in your code that will display the results alright.Do you mean that you want to display the results in a specific area of an HTML page?
just put the echo thing inside the table.
php Syntax (Toggle Plain Text)
$query = "SELECT * FROM customers WHERE job_number='$jobnumber'"; $result = mysql_query($query); echo "<table>"; while ($row = mysql_fetch_array($result)){ echo "<tr>" echo "<td>$row['first_name']</td>"; echo "<td>$row['last_name']</td>"; echo "<td>$row['email']</td>"; echo "</tr>"; //etc... } echo "</table>";
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I seem to be getting this error: Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in getjobnumber.php on line 30
Here's how I wrote it:
Line 30 =
It's highlighted in thick red. Thanks again.
Here's how I wrote it:
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['submit'])) { $jobnumber=$_POST['jobnumber']; //connect $query = "SELECT * FROM customers WHERE job_number='$jobnumber'"; $result = mysql_query($query); echo "<table>"; while ($row = mysql_fetch_array($result)) { echo "<tr>" echo "<td>$row['first_name']</td>"; echo "<td>$row['last_name'];</td>"; echo "<td>$row['email'];</td>"; echo "</tr>"; //etc... } echo "</table>"; } ?>
Line 30 =
echo "<td>$row['first_name']</td>"; It's highlighted in thick red. Thanks again.
Last edited by peter_budo; Apr 5th, 2008 at 1:28 pm. Reason: [icode] is for one line of code, [code] is for multiple lines
you have mistakenly put ";" in this line:
erase it and it will be fine.
echo "<td>$row['last_name'];</td>"; erase it and it will be fine.
Last edited by peter_budo; Apr 5th, 2008 at 1:29 pm. Reason: Keep It Organized - please use [code] tags
and also in here:
I am referring to the ";" in the middle.
echo "<td>$row['email'];</td>"; I am referring to the ";" in the middle.
Last edited by peter_budo; Apr 5th, 2008 at 1:29 pm. Reason: Keep It Organized - please use [code] tags
![]() |
Similar Threads
- Displaying images from mysql database (PHP)
- Listbox is not displaying the correct information if at all (PHP)
- pagination not displaying results (PHP)
- Paging Problem (PHP)
- error in myvehicle.php! (PHP)
- Looping through arrays (PHP)
- Storing dynamic form values in Arrays for display & insert (PHP)
Other Threads in the PHP Forum
- Previous Thread: <textarea> readonly
- Next Thread: Send variable from javascript to php?
| Thread Tools | Search this Thread |
# 5.2.10 ajax apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date display dissertation dynamic echo echo$_get[x]changingitintovariable... email error file files folder form forms function functions google href htaccess html image images include insert integration ip java javascript joomla ldap legislation limit link local login loop mail memberships menu mlm multiple multipletables mysql mysqlquery oop open paypal pdf persist php problem query radio random recursion regex remote rss script search server sessions sms soap sockets source space spam sql syntax system table tutorial update upload url validator variable video web xml youtube






