0

Hi is this correct syntax......i want the values which are displayed from the table should be stored in an array .......

<?php

	include('database.php');


 $stype=$_POST['category'];


if($stype=="service_category")
   { 
	 
	  $result = mysql_query("SELECT * FROM  service_category ");

	while($row = mysql_fetch_array($result))
	{

	?>

	<input type="Checkbox" id="a[]"  value="servicec"><?echo $row['servicec'];
	echo "<br />";
	for($i=0;$i<6;$i++)
		{
		   $a[i]=$row['servicec'];
		}
	}

   }
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Shanti C
0

no, this code is not correct.

while($row = mysql_fetch_array($result))
{
?>
$a[i]=$row['servicec'];
$i++;
}
0

See this:

function get_all_listings() { 
  $query = "SELECT * FROM `metlistings`";
		
  $result = mysql_query($query) or die(mysql_error());
		
  //Count the rows retrieved
  $count = mysql_num_rows($result);	
  for ($i = 0; $i <= $count; $i++) {						    
    while($row = mysql_fetch_array($result)) {
	$title = stripslashes($row['metName']);
	$link = $row['metId'];
	$arr = array("listings" => array("total" => $count, "data" => array($i => $link)));
	
    return $arr; //doest not work
					
    //print_r($arr); //works fine
			
	}
     }
 
}
 
$test = get_all_listings();
for($i = 1; $i <= $test["listings"]["total"]; $i++) { 
 
  echo $test["listings"]["data"][$i];
	
}
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.