Trouble in dispalying a recordset plus an output.
Posted: Thu Apr 10, 2008 11:47 am
Everah | Please use the correct bbCode tags when posting code in the forums. You can use [code], [php], [{lang}] or [syntax="{lang}"] where {lang} is the lowercase string name of the language you want to parse.
hi guys thx for reading this! Ok here is the deal, I am building an admin panel and i have written a recordset so to display some fields from my database. This would be my list so i can delete or update an entry from my database. This is my code:
As you can see i Include a file called uploadform.php which is going to help to upload images.. this is the code:
As you already understand the $output var in first script comes from the uploadform.php!
HERE IS THE PROBLEM I NEED TO SOLVE How can I get the $codeno var of all my records seperatly in uploadform action without displaying the $output more than one time.(this is what happens when i put the include inside the while loop).Guys I would be grateful to you if you could help me out!
Everah | Please use the correct bbCode tags when posting code in the forums. You can use [code], [php], [{lang}] or [syntax="{lang}"] where {lang} is the lowercase string name of the language you want to parse.
hi guys thx for reading this! Ok here is the deal, I am building an admin panel and i have written a recordset so to display some fields from my database. This would be my list so i can delete or update an entry from my database. This is my code:
Code: Select all
<body>
<?php echo '<p><left><a href="insert_record.php">Add a new record</a></left></p>';
include "/usr/home/mysite.com/htdocs/inc/dbconn.php";
$q = "select codeno, brief, type, resort from estateinfo";
if ($sortby){
$q=$q." order by $sortby";
}
$result = mysql_query($q);
$num_rows=mysql_num_rows($result);
echo '<center>';
echo "<h1> REAL ESTATE</h1></br>";
echo "<h2>ESTATE LIST</h2>";
echo "</center>";
echo "<table border=\"0\" cellpadding=\"5\" align=\"center\">";
echo '<tr>';
echo "<td><a href=edit.php?sortby=codeno>ID</a></td>";
echo "<td><a href=edit.php?sortby=type>CATEGORY</a></td>";
echo "<td><a href=edit.php?sortby=resort>LOCATION</a></td>";
echo "<td>BRIEF</td>";
echo '</tr>';
while ($row= mysql_fetch_array($result,MYSQL_BOTH))
{
echo '<tr>';
$codeno=$row['codeno'];
[color=#0000FF]include('inc/uploadform.php');[/color]
$type=$row['type'];
$resort=$row['resort'];
$brief=$row['brief'];
echo "<td>$codeno</td>";
echo "<td>$type</td>";
echo "<td>$resort</td>";
if (strlen($brief)>strlen(substr($brief,0,50))){
echo '<td>'.substr($brief,0,50).'...</td>';
}
else {echo "<td>$brief</td>";}
echo "<td><a href = update_estate.php?id=$codeno>Edit</a></td>";
echo "<td><a href = delete_estate.php?id=$codeno>Delete</a></td>";
echo "</tr>";
echo '<tr>';
echo '<td colspan=\"6\">';
echo "$output";
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan=\"6\">';
echo '<br />';
echo '</td>';
echo '</tr>';
}
echo "</table>";
echo "<center>";
echo '<a href="insert_record.php">Add a new record</a>'.' | '.'<a href="list.php">refresh</a>';
echo "</center>";
?>
</body>Code: Select all
<?php
$output .= "
<table width=\"100%\" cellpadding='0' cellspacing='0'>
<tr><td><form enctype=\"multipart/form-data\" action=\"../[color=#FF0000]uploader.php?id=$codeno[/color]\" method=\"POST\">";
$maxsize = ini_get('upload_max_filesize');
if (!is_numeric($maxsize))
{
if (strpos($maxsize, 'M') !== false)
$maxsize = intval($maxsize)*1024*1024;
elseif (strpos($maxsize, 'K') !== false)
$maxsize = intval($maxsize)*1024;
elseif (strpos($maxsize, 'G') !== false)
$maxsize = intval($maxsize)*1024*1024*1024;
}
$output .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . $maxsize.'\" />';
$output .= "
Choose an image :
<input name=\"uploadedfile\" type=\"file\" class=\"Button\" />
<input type=\"submit\" class=\"Button\" value=\"Upload File\" />
<input type=\"hidden\" name=\"codeno\" value=\"$codeno\" />
</form></td></tr></table>
";
?>HERE IS THE PROBLEM I NEED TO SOLVE How can I get the $codeno var of all my records seperatly in uploadform action without displaying the $output more than one time.(this is what happens when i put the include inside the while loop).Guys I would be grateful to you if you could help me out!
Everah | Please use the correct bbCode tags when posting code in the forums. You can use [code], [php], [{lang}] or [syntax="{lang}"] where {lang} is the lowercase string name of the language you want to parse.