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")
$result=mysql_query("select first name,middlename, party from candidate") or
die (mysql_error());
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...

Member Avatar for langsor

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.


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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.