•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,716 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,539 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 695 | Replies: 31 | Solved
![]() |
•
•
Join Date: Apr 2008
Location: Lahore, Pakistan
Posts: 36
Reputation:
Rep Power: 1
Solved Threads: 1
you can use mysql_fetch_assoc in the following.
this is wat i know but i may be wrong.
this is wat i know but i may be wrong.
php Syntax (Toggle Plain Text)
while( $list=mysql_fetch_assoc($result)) { foreach($list as $val) { echo $val; } echo "<br />"; }
•
•
Join Date: Mar 2008
Posts: 85
Reputation:
Rep Power: 1
Solved Threads: 0
I added the extra die functions, and I tried to change but it's not working.
Instead, I'm getting a strange error that says: Unknown column 'Justin' in 'where clause'
Justin is the test name I have in the database. I'm stumped.
So what I have now looks like this:
[icode] <?php
// Include connection to your database
$con = mysql_connect("localhost","root","rilke123");
mysql_select_db("RUNNERS", $con) or die(mysql_error());
$name = $_POST['first'];
$query = "SELECT * FROM runners WHERE id =".$name;
$result = mysql_query($query) or die(mysql_error());?>
<table class="sortable">
<!-- Table Header -->
<thead>
<tr>
<th>ID #</th>
<th>First Name</th>
<th>Last Name</th>
<th>1 Mile</th>
<th>2 Mile</th>
<th>5k</th>
<th>8k</th>
<th>10k</th>
<th>20k</th>
<th>13.1</th>
<th>26.2</th>
</tr>
</thead>
<!-- Table body-->
<tbody>
<?php while ($list = mysql_fetch_assoc($result)) ?>
<tr>
<th><?php echo $list['first_name'] ?></th>
<th><?php echo $list['last_name'] ?></th>
<th><?php echo $list['one'] ?></th>
<th><?php echo $list['two'] ?></th>
<th><?php echo $list['five'] ?></th>
<th><?php echo $list['ten'] ?></th>
<th><?php echo $list['fifteen'] ?></th>
<th><?php echo $list['twenty'] ?></th>
<th><?php echo $list['half'] ?></th>
<th><?php echo $list['full'] ?></th>
</tr>
</tbody>
[/code]
Thanks again!
$list=mysql_fetch_array($result); to this while( $list=mysql_fetch_assoc($result))
{
foreach($list as $val)
{
echo $val;
}
echo "<br />";
}Instead, I'm getting a strange error that says: Unknown column 'Justin' in 'where clause'
Justin is the test name I have in the database. I'm stumped.
So what I have now looks like this:
[icode] <?php
// Include connection to your database
$con = mysql_connect("localhost","root","rilke123");
mysql_select_db("RUNNERS", $con) or die(mysql_error());
$name = $_POST['first'];
$query = "SELECT * FROM runners WHERE id =".$name;
$result = mysql_query($query) or die(mysql_error());?>
<table class="sortable">
<!-- Table Header -->
<thead>
<tr>
<th>ID #</th>
<th>First Name</th>
<th>Last Name</th>
<th>1 Mile</th>
<th>2 Mile</th>
<th>5k</th>
<th>8k</th>
<th>10k</th>
<th>20k</th>
<th>13.1</th>
<th>26.2</th>
</tr>
</thead>
<!-- Table body-->
<tbody>
<?php while ($list = mysql_fetch_assoc($result)) ?>
<tr>
<th><?php echo $list['first_name'] ?></th>
<th><?php echo $list['last_name'] ?></th>
<th><?php echo $list['one'] ?></th>
<th><?php echo $list['two'] ?></th>
<th><?php echo $list['five'] ?></th>
<th><?php echo $list['ten'] ?></th>
<th><?php echo $list['fifteen'] ?></th>
<th><?php echo $list['twenty'] ?></th>
<th><?php echo $list['half'] ?></th>
<th><?php echo $list['full'] ?></th>
</tr>
</tbody>
[/code]
Thanks again!
Last edited by justinmyoung : Jul 25th, 2008 at 10:17 am. Reason: added code
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 592
Reputation:
Rep Power: 2
Solved Threads: 52
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 592
Reputation:
Rep Power: 2
Solved Threads: 52
right under this line
put
run it, copy the results, and post it.
$query = "SELECT * FROM runners WHERE id = '$name'";
put
echo $query;
run it, copy the results, and post it.
Last edited by R0bb0b : Jul 25th, 2008 at 6:46 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
•
•
Join Date: Apr 2008
Location: Lahore, Pakistan
Posts: 36
Reputation:
Rep Power: 1
Solved Threads: 1
•
•
Join Date: Mar 2008
Posts: 85
Reputation:
Rep Power: 1
Solved Threads: 0
Here's the table structure:
CREATE TABLE IF NOT EXISTS `runners` ( `id` mediumint(50) unsigned NOT NULL auto_increment, `first_name` varchar(50) NOT NULL, `last_name` smallint(50) NOT NULL, `one` smallint(50) NOT NULL, `two` smallint(50) NOT NULL, `five` smallint(50) NOT NULL, `ten` smallint(50) NOT NULL, `fifteen` smallint(50) NOT NULL, `twenty` smallint(50) NOT NULL, `half` smallint(50) NOT NULL, `full` smallint(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `runners` -- INSERT INTO `runners` (`id`, `first_name`, `last_name`, `one`, `two`, `five`, `ten`, `fifteen`, `twenty`, `half`, `full`) VALUES (1, 'Justin', 0, 400, 800, 1300, 2700, 4500, 5800, 6000, 20000);
Last edited by Tekmaven : 34 Days Ago at 3:42 am. Reason: Code Tags
•
•
Join Date: Apr 2008
Location: Lahore, Pakistan
Posts: 36
Reputation:
Rep Power: 1
Solved Threads: 1
ive found ur mistake. ur using
the following,
do this,
u are using the wrong field. u are comparing an int field with string and ur are comparing the id field with the name.
the following,
php Syntax (Toggle Plain Text)
$name = $_POST['first']; $query = "SELECT * FROM runners WHERE id =".$name;
do this,
php Syntax (Toggle Plain Text)
$name = $_POST['first']; $query = "SELECT * FROM runners WHERE first_name =".$name;
u are using the wrong field. u are comparing an int field with string and ur are comparing the id field with the name.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
access advice age amd avatar backup blue gene combo daniweb data data protection database dos dropdownlist economy encryption energy europe forensic forensics hardware help ibm ibm. news intel ibm it linux medicine memory microsoft module news open source openoffice pc privacy ps3 recession red hat russia security server storage sun supercomputer supercomputing technology trends web working
- Pulling Data from two tables (PHP)
- Help with query (PHP)
- ORA-01013: user requested cancel of current operation (C#)
- ORA-01013: user requested cancel of current operation (ASP.NET)
- I am working on an ASP.net 2.0 application written in C#, pulling data from an Oracle (Oracle)
- Need help passing database column value to a string variable. (ASP.NET)
- code optimization ... (C++)
- Inserting Data into Access Database (Java)
- ASP.NET Tutorial: Caching in ASP.NET (ASP.NET)
- Can this be done? (MS Access and FileMaker Pro)
Other Threads in the PHP Forum
- Previous Thread: How use the bcc field
- Next Thread: is there any way to submit a form to a number of pages at the same time?


Linear Mode