Jump to content

Some columns are not being echoed with mysql_fetch_array


macattack

Recommended Posts

Hello,

 

I have mysql query that is returning the first five people that need to be called,

$sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5";

 

When I do mysql_fetch_assoc it works for every value except the V_ID value. The values are being printed to a table. It's not showing any errors. If anyone has a solution for this (likely simple) error, please let me know! Also, all values are varchar except V_ID. Thanks in advance!

What does your code look like that outputs the information and have you done a "view source" in your browser to see what is actually there and is there actually data in that column for the row(s) that are returned?

The entire output works, with the exception of the V_ID row. The code is pasted below.

 

$sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5";

$query = mysql_query($sql);

while($row = mysql_fetch_assoc($query)){
echo "<form action='dbupdate.php?task=call&poll=".$_GET['poll']."' method='post'>
		<input type='hidden' name='ID' value='".$row['V_ID']."'>
		<tr>
			<td><input type='hidden' name='surname' value=".$row['Surname']."'>".$row['Surname']."</td>
			<td><input type='hidden' name='name' value=".$row['Name']."'>".$row['Name']."</td>
			<td><input type='hidden' name='middle' value=".$row['Middle']."'>".$row['Middle']."</td>
			<td><input type='hidden' name='phone' value='".$row['Phone']."'>".$row['Phone']."</td>
			<td><input type='text' length='4' size='6' name='unit' value='".$row['Unit']."'></td>
			<td><input type='text' length='10' size='7' name='number' value='".$row['Number']."'></td>
			<td><input type='text' length='30' size='15' name='street' value='".$row['Street']."'></td>
			<td><input type='text' length='3' size='5' name='streettype' value='".$row['StreetType']."'></td>
			<td><input type='text' length='7' size='7' name='postal' value='".$row['Postal']."'></td>
			<td>
				<select name='call'>
					<option></option>
					<option value='1'>Reached</option>
					<option value='2'>Left Message</option>
					<option value='3'>No Answer</option>
					<option value='4'>Wrong Number</option>
				</select>
			</td>
			<td>
				<select name='support'>
					<option></option>
					<option value='pc' ";
					if($row['Support'] == 'pc'){ echo "selected"; }
					echo ">PC</option>
					<option value='lib' ";
					if($row['Support'] == 'lib'){ echo "selected"; }
					echo ">Liberal</option>
					<option value='NDP' ";
					if($row['Support'] == 'ndp'){ echo "selected"; }
					echo ">NDP</option>
					<option value='grn' ";
					if($row['Support'] == 'grn'){ echo "selected"; }
					echo ">Green</option>
					<option value='acc' ";
					if($row['Support'] == 'acc'){ echo "selected"; }
					echo ">Accessible/maybe PC</option>
					<option value='oth' ";
					if($row['Support'] == 'oth'){ echo "selected"; }
					echo ">Other</option>
				</select>
			</td>
			<td><input type='text' length='10' size='12' name='partymember' value=".$row['Partymember']."></td>
			<td><input type='checkbox' name='sign' value='R'></td>
			<td><input type='checkbox' name='volunteer' value='Y'></td>
			<td><input type='text' name='email' maxlength='50' value='".$row['Email']."'></td>
			<td><input type='checkbox' name='donate' value='y'></td>
			<td><input type='checkbox' name='nocall' value='1'></td>
			<td><input type='submit'></td>
		</tr></form>";
}

 

As for the view source, again, same answer. Everything was displaying as it should, with the exception of the V_ID.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.