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...

Edited by mike_2000_17: Fixed formatting

8 Years
Discussion Span
Last Post by 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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.