reservoirdoggy
08-31-2011, 07:11 PM
I cannnot find a good answer for me on this subject. I'm looping through a dynamic sql query to get different results from the same two columns. Eventually I want to have dynamic text areas. This worked before I tried to do it dynamically.. I check dynamic checkboxes on one page, pass the values over to the next page, and then try to loop through to get the code, code descr from the db. The link to the site is..
http://www.dataspiral.com/WholeDocPhp_VisitNotesList.php
The code on the page receiving the posted data is:
<?php
$count = 3;
$i=0;
while ($i < $count){
echo $i;
$Code= $_POST[$i];
echo $Code;
$dbconnection = mysql_connect(host, database, password) or die("Died!");
echo "Connected to MySQL". '<br />';
mysql_select_db("dbwholedoc",$dbconnection) or die("Died!");
echo "Connected to Database". '<br />';
if ($Code <>''){
$sql = ("SELECT Code, CodeDescr FROM VisitCodes where Code = '".$Code."'");
echo "Query: " . $sql;
$result=mysql_query($sql);
${'code'.$i}=mysql_result($result,$i,"Code");
${'codeDescr'.$i}=mysql_result($result,$i,"CodeDescr");
echo $code0;
echo $codedescr0;
}
/*result not coming through query for code and codedescr... query not executing correctly*/
$num=mysql_num_rows($result);
echo $num;
?>
<?php
mysql_close();
$i++;
}
?>
Thanks in advance!
http://www.dataspiral.com/WholeDocPhp_VisitNotesList.php
The code on the page receiving the posted data is:
<?php
$count = 3;
$i=0;
while ($i < $count){
echo $i;
$Code= $_POST[$i];
echo $Code;
$dbconnection = mysql_connect(host, database, password) or die("Died!");
echo "Connected to MySQL". '<br />';
mysql_select_db("dbwholedoc",$dbconnection) or die("Died!");
echo "Connected to Database". '<br />';
if ($Code <>''){
$sql = ("SELECT Code, CodeDescr FROM VisitCodes where Code = '".$Code."'");
echo "Query: " . $sql;
$result=mysql_query($sql);
${'code'.$i}=mysql_result($result,$i,"Code");
${'codeDescr'.$i}=mysql_result($result,$i,"CodeDescr");
echo $code0;
echo $codedescr0;
}
/*result not coming through query for code and codedescr... query not executing correctly*/
$num=mysql_num_rows($result);
echo $num;
?>
<?php
mysql_close();
$i++;
}
?>
Thanks in advance!