I have added 3 radio buttons to a form (no errors prior to this) for option to sort fetch_array result by field. I assume this is best done from the array but am making no progress - the results of $name,print_r($array) and tables are correct but no sorting.
This Notice appears: **Uninitialized string offset: **0 in C:........on line 78
from this extract
<form method="post" name="search" action="workingjoinIDtest.php"/>
<font family = "arial,verdana,sans-serif" color="#3F7cef"size="4"/>Enter Ship Name or IMO</font>
<input type="text" name="name" size="25" maxlength ="35"/>
<input type="image" name="submit" src="texts/cooltext591383228.png" onmouseover="this.src='texts/cooltext591383228MouseOver.png';" onmouseout="this.src='texts/cooltext591383228.png';" alt="search"><br/>
<font family = "arial,verdana,sans-serif" color="#3F7cef"size="4">
<p><label><input type="radio" name="sequence" value="alpha" checked="yes">Sort A-Z</p>
<p><label><input type="radio" name="sequence" value="tons">Sort by GRT</p>
<p><label><input type="radio" name="sequence" value="built">Sort by Year Built</p></font>
</form>
<div class="printarea"/> <!--line 43 -->
<?php //4 MySQL queries-allnames,launch,fate,imocode
if (isset($_POST['name'])) $name = ($_POST ['name']);
else $name = "no name entered"; //display "no name entered"
if($name =="") //if submit pressed with no name entered
{
echo "<p><font color='red' size='6px'>You have not entered a name</font></p>";
exit;
echo"<br />";
}
require_once 'dbconnect.php';
$name = strtoupper($name);
$name = strip_tags($name);
$name = trim ($name);
$name = mysql_real_escape_string($name); // line 57
$query = "(SELECT * FROM launch JOIN allnames ON launch.id=allnames.id JOIN fate ON fate.id=allnames.id JOIN imocode ON imocode.id=fate.id WHERE name1 LIKE '$name%' OR name2 LIKE '$name%' OR name3 LIKE '$name%' OR name4 LIKE '$name%' OR name5 LIKE '$name%' OR name6 LIKE '$name%' OR name7 LIKE '$name%' OR name8 LIKE '$name%' OR name9 LIKE '$name%' OR name10 LIKE '$name%' OR name11 LIKE '$name%' OR name12 LIKE '$name%'OR name13 LIKE '$name%' OR name14 LIKE '$name%' OR name15 LIKE '$name%'OR name16 LIKE '$name%' OR name17 LIKE '$name%')UNION(SELECT * FROM launch JOIN allnames ON launch.id=allnames.id JOIN fate ON fate.id=allnames.id JOIN imocode ON imocode.id=fate.id WHERE code LIKE '%$name%')";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows=mysql_num_rows($result);
echo "<font color='#3F7cef'size='4'/>You searched for:</font>";
echo "<p>"; //<br /> justifies left and leaves no spaces
echo "<font color='#3F7cef'size='6'>";
require_once "fix_it.php"; // works equally with name and code input
echo fix_it($name);
echo "</font>";
if (mysql_num_rows($result)== 0) //line 68
echo "<p><font color='red'size='6px'>No data found for your request. Try a different query</font>";
while($row = mysql_fetch_array($result)){
$array = $row;
echo "<br />";
echo "<p><font color='#3F7cef'size='5'>$row[32]</font>"; // sets imocode field
if (!function_exists('compare_tons')){
if($sequence='tons') {
function compare_tons($a,$b)
{
return strnatcmp($a['tons'],$a['tons']);
}
uasort($array,"compare_tons");
}
}
print_r($array); // enable this line to show all fields in array
require_once "launch_tableID.php"; //prints launch table with ID number
echo launch_tableID();
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td><td>";
if($row[6] > 0000-00-00)
...continues to end ?>
I must be completely wrong, can someone point me in right direction, please ?