I'm having a problem in displaying data from the table.I've a candidate table in the db. i 've got the problem when i try to select the place of the candidate in the main html code. the html has the place selector, frist name, middle name and partystatus of it. when i try to select the place it should retrive from the db table. and displays the names and party status. i wrote the php code to track this

if ($place == "zone")
{
$w=0;
$result=mysql_query("select first name,middlename, party from candidate") or
die (mysql_error());
//$row=mysql_fetch_array($result);
while ($row=mysql_fetch_array($result))
{

echo' $first name:$row["firstname"] 
        $middlename: $row["midddlename"]
        $party: $row["party"]
}

i wrote it like this but it has a problem, i want it to count and find the place and the row.. check it for me...

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This probably wont fix your problem, but I found error in the SQL statement and also in the echo statement -- I strongly suggest you study up on the string data-type.

http://www.php.net/manual/en/language.types.string.php

In the meantime I fixed what I could. I don't know if you need your SQL statement to have WHERE field=condition type clauses ...

$result = mysql_query( "SELECT firstname, middlename, party FROM candidate" ) or die (mysql_error());
while ( $obj = mysql_fetch_object( $result ) ) {
  echo "$first {$namerow['firstname']} $middlename: $obj->midddlename $party: $obj->party";
}

Really I'm not seeing clearly all the variables you are using here ... ?

Good luck

This article has been dead for over six months. Start a new discussion instead.