Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 How to retrieve all (1000) chars from DB to PHP

Author  Topic 

vaishjan
Starting Member

8 Posts

Posted - 2004-12-15 : 07:21:04
Hi,

Plz do help to solve.

MS SQL Server 2000 database has 2 fields, one with varchar of 1000 characters & nvarchar(1000)and 1000 characters are stored in the database.

when i retrieve thru' select query and place it in textarea i am not receiving the entire information rather a truncated value of 256 characters only.

How to rectify it and get all the 1000 chars present in the database?

Thnx in Advance

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-12-15 : 08:37:26
This is probably a PHP issue, you may need to post on a PHP forum. You should try this link if you haven't already:

http://www.php.net/
Go to Top of Page

vaishjan
Starting Member

8 Posts

Posted - 2004-12-23 : 03:19:32
Hi Pals,

I have made use of substring() in DB to receive all 1000 chars.

Another ISSUE:
Can anyone provide a limelight to introduce MVC design pattern in PHP code which goes with HTML as well.

Thanx in Advance.

Here is a sample code. How to introduce the MVC Pattern in this code?

File Name - HotelAmenities_New.php

<?
session_start();
session_register("username");
$usr = $_SESSION["username"];
?>
<!--
Author : S.Vaishnavi

The Form requests for PropertyNo and data that is inserted or selected thru' the help of controls like radio button, textbox etc. are inserted to the database.
Insert Query is used for the process.

Program Name : HotelAmenities_New.php
-->
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="common.css">
<title>Hotel Interface</title>
<!--
Javascript is used for submission to the same form when OnChange action takes place
-->
<Script Language="Javascript">
function selvalid()
{
document.myform.action = "HotelAmenities_New.php?req=1";
document.myform.submit();
}
</Script>
</head>

<body bgcolor="#ECE9d8">
<table border="0" cellpadding="1" cellspacing="0" width="100%" bgcolor="#ECE9d8" align="center">
<tr>
<td width="100%" valign="top" align="left" >

<!--*********** Begins Topmenu ***************-->
<?php
include 'topmenu.php';
?>

<!-- Database Connection file included -->
<?php
include 'db_connection.inc.php';
?>
</td>
</tr>
<!--*********** End of Topmenu ***************-->
<?
// Check for Session Variable. If exist, Proceed
if ($usr == "")
{
echo "<tr><td colspan=3> </td></tr>";
echo "<td colspan=3 align=center><div class=hr>Session
Expired, Please login</td></tr>";
echo "<tr><td colspan=3 align=center><a class=top
href='index.php'>Login</a></td></tr>";
}
else
{
?>
<tr>
<td width="100%" align="center" >
<!--*********** Contents of the Body Begins***************-->
<table border=0 cellspacing=1 cellpadding=1 width="100%">
<tr bgcolor="#721309">
<!-- Display Page heading -->
<td align=center colspan=3>
<div class=h4>
Add Hotel Amenity/Feature
</div>
</td>
</tr>

<tr><td colspan=3> </td></tr>

<?
/*
Req value is requested when Onchange action takes place along with it PropertyNo (pid) is as well requested
*/
$reqst = empty($_REQUEST["req"]) ? '' : $_REQUEST["req"];
$pid= empty($_REQUEST["Pno"])?'' : $_REQUEST["Pno"];

// if req value is 1, Proceed
if($reqst == 1)
{
// Requesting for PropertyNo indirectly from the
HotelAmenities_View form
$pid= empty($_REQUEST["Pno"])?'' : $_REQUEST["Pno"];

// New HotelAmenityID (ID) is requested after onchange action takes place
$ID = empty($_REQUEST["cmbHotelFacility"]) ? '' : $_REQUEST
["cmbHotelFacility"];

/*
Selection of all fields form HotelAmenitiesMaster database, where the already existing amenities for the Property is not considered. Only all those amenities which are not currently present for the Property is listed for selection by the user
*/
$SelNAmenity="SELECT * FROM HotelAmenitiesMaster WHERE HotelAmenityID NOT IN(SELECT HotelAmenityID FROM HotelAmenityFeatures WHERE PropertyNo=$pid) and HotelAmenityID=$ID";
$resultNAmenity = mssql_query($SelNAmenity);
$SelAmenity="SELECT * FROM HotelAmenitiesMaster WHERE HotelAmenityID NOT IN(SELECT HotelAmenityID FROM HotelAmenityFeatures WHERE PropertyNo=$pid) ORDER BY HotelFacility";
$resultAmenity=mssql_query($SelAmenity);
?>

<form name="myform" method="POST" action="Con_HotelAmenities_New.php">
<?
// Select the PropertyName from PropertyMaster based on the PropertyNo
$selhname = "SELECT PropertyName From PropertyMaster where PropertyNo=$pid";
$rs = mssql_query($selhname);
$pname = mssql_fetch_row($rs);
?>
<tr>
<td width="20%">
<div class=h5b>Property Name</div>
</td>
<td colspan=2>
<!-- Pno & Pname are passed as hidden value along with the printing of PropertyName
-->
<input type="hidden" name="Pno" value="<?print("$pid"); ?>">
<input type="hidden" name="txtPropertyName" value="<?print ("$pname[0]") ?>" class="txt1">
<font face="Verdana" size=2><?print "$pname[0]"; ?></font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Hotel Facility</div>
</td>
<td colspan=2>
<div class=h5>
<!-- OnChange of selection of the value Javascript is used -->
<select name="cmbHotelFacility" class="txt1" onChange="return selvalid();">
<?
for ($i = 0; $i < mssql_num_rows( $resultNAmenity ); ++$i)
{
$line = mssql_fetch_row($resultNAmenity);
?>
<option value='<? print("$line[0]");?>'>
<?
print("$line[1]<br>\n");
?>
</option>
<?
}
?>
<?
for ($i = 0; $i < mssql_num_rows( $resultAmenity ); ++$i)
{
$line = mssql_fetch_row($resultAmenity);
?>
<option value='<? print("$line[0]");?>'>
<?
print("$line[1]<br>\n");
?>
</option>
<?
}
?>
<!-- Link helps to take U to Master database -->
</select>
<a class=top href="HotelAmenitiesMaster.php">Add Hotel Facility</a>
</div>
</td>
<td>
</td>
</td>
</tr>

<tr>
<td colspan=3>
<input type="hidden" name="txtHotelAID" value="<?print ("$ID") ?>" >
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Description</div></td>
<td colspan=2>
<?
/*
Description from master database is selected for the new selection of Hotel Facility
*/
$SelDesc="SELECT Description FROM HotelAmenitiesMaster WHERE HotelAmenityID= $ID";
$resultDesc = mssql_query($SelDesc);
for ($i = 0; $i < mssql_num_rows( $resultDesc ); ++$i)
{
$line = mssql_fetch_row($resultDesc);
?>
<!--<textarea rows="3" name="txtDesc" cols="25" class="txt1" value ="<? print("$line[0]"); ?>"-->
<font face="Verdana" size=2><? print("$line[0]"); ?></font>
<!--</textarea>-->
<?
}
?>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Available To All</div>
</td>
<td colspan=2>
<input type="radio" CHECKED value="Y" name="optAvailAll" class="txt1"><font face="Verdana" size=2>Yes</font>  
<input type="radio" value="N" name="optAvailAll" class="txt1"><font face="Verdana" size=2>No</font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Charges for Usage</div>
</td>
<td colspan=2>
<input type="radio" CHECKED value="Y" name="optChargeUse" class="txt1"><font face="Verdana" size=2>Yes</font>  
<input type="radio" value="N" name="optChargeUse" class="txt1"><font face="Verdana" size=2>No</font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Hours Of Operation</div>
</td>
<td colspan=2>
<input type="text" name="txtHrsofOprn" size="20" class="txt1" maxlength="20">
<input type="hidden" name="txtPno" size="20" value="<?print("$pid"); ?>" class="txt1">
</td>
</tr>
<tr>
<td colspan=3> </td>
</tr>

<tr>
<td width="15%"> </td>
<td width="85%" colspan=2 >
<!--
Save takes to Con_HotelAmenities_New.php where Insertion process is handled
-->
<input type="submit" value="Save" name="btSubmit" class=sub>

<!-- Reset button resets to the previous value -->
<input type="reset" value="Reset" name="B2" class=sub>

<!--
Back takes to HotelAmenities_View where report format resides which is taken care by Javascript
-->
<input type="button" value="Back" onclick="return valid();" class=sub>

<!-- Main Menu takes to Menu page which is handled thru' Javascript -->
<input type="button" value="Main Menu" onclick="return valid2();" class=sub>
</td>
</tr>
</form>
<?
}
else
{ /*
This part is executed when this form is called for the first time, ie - On Click of the Edit Link in HotelAmenities_View.
*/
?>
<form name="myform" method="POST" action="HotelAmenities_New.php?req=1" onsubmit="return valid1( this );">
<?
// Requesting for PropertyNo from the HotelAmenities_View form
$pid= empty($_REQUEST["Pno"])?'' : $_REQUEST["Pno"];

/*
Selecting all fields from master table where already existing amenity for the property is not considered and those amenity that are selected are placed in the list in alphabetical order of Hotel Facility
*/
$SelNAmenity="SELECT * FROM HotelAmenitiesMaster WHERE HotelAmenityID NOT IN(SELECT HotelAmenityID FROM HotelAmenityFeatures WHERE PropertyNo=$pid) ORDER BY HotelFacility";
$resultNAmenity = mssql_query($SelNAmenity);
?>
<tr>
<td>
<input type="hidden" name="Pno" value="<?print ("$pid"); ?>" >
</td>
</tr>

<?
// Select the PropertyName from PropertyMaster based on the PropertyNo
$selhname = "SELECT PropertyName From PropertyMaster where PropertyNo=$pid";
$rs = mssql_query($selhname);
$pname = mssql_fetch_row($rs);
?>
<tr>
<td width="20%">
<div class=h5b>Property Name</div>
</td>
<td>
<input type="hidden" name="txtPropertyName" value="<?print ("$pname[0]") ?>" class="txt1">
<font face="Verdana" size="2"><?print "$pname[0]"; ?></font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Hotel Facility</div>
</td>
<td width="15%">
<div class=h5>
<input type="hidden" name="Pno" value="<? print ($pid);?>">
<select name="cmbHotelFacility" class="txt1" onChange="Javascript: document.myform.submit();">
<option value="facility">Select Facility</option>
<?
for ($i = 0; $i < mssql_num_rows( $resultNAmenity ); ++$i)
{
$line = mssql_fetch_row($resultNAmenity);
?>
<option value='<? print("$line[0]");?>'>
<?
print("$line[1]<br>\n");
?>
</option>
<?
}
?>
</select>
</div>
</td>
<td>
<a class=top href="HotelAmenitiesMaster.php">Add Hotel Facility</a>
</td>
</td>
</tr>
<?
$ID = empty($_REQUEST["cmbHotelFacility"]) ? '' : $_REQUEST["cmbHotelFacility"];
$reqst = empty($_REQUEST["req"]) ? '' : $_REQUEST["req"];
?>
<tr>
<td width="15%">
<div class=h5b>Description</div></td>
<td>
<div class=h5>
<!--<textarea rows="3" name="txtDesc" cols="25" class=""txt1"" >
</textarea>-->
</div>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Available To All</div>
</td>
<td>
<input type="radio" CHECKED value="Y" name="optAvailAll" class="txt1">
<font face="Verdana" size="2">Yes</font>  
<input type="radio" value="N" name="optAvailAll" class="txt1">
<font face="Verdana" size="2">No</font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Charges for Usage</div>
</td>
<td>
<input type="radio" CHECKED value="Y" name="optChargeUse" class="txt1"><font face="Verdana" size=2>Yes</font>  
<input type="radio" value="N" name="optChargeUse" class="txt1"><font face="Verdana" size=2>No</font>
</td>
</tr>

<tr>
<td width="15%">
<div class=h5b>Hours Of Operation</div>
</td>
<td>
<input type="text" name="txtHrsofOprn" size="20" class="txt1">
</td>
</tr>

<tr>
<td colspan=3> </td>
</tr>

<tr>
<td width="15%"> </td>
<td width="60%" colspan=2>
<!-- Save takes to the same form with req=1 -->
<input type="hidden" name="Pno" value='<?print("$pid"); ?>'>
<input type="hidden" name="txtHotelAID" value="<? print("$ID");?>">
<input type="submit" value="Save" name="btSubmit" class=sub>

<!-- Reset button resets to the previous value -->
<input type="reset" value="Reset" name="B2" class=sub>

<!--
Back takes to HotelAmenities_View where report format resides which is taken care by Javascript
-->
<input type="button" value="Back" onclick="return valid();" class=sub>

<!-- Main Menu takes to Menu page which is handled thru' Javascript -->
<input type="button" value="Main Menu" onclick="return valid2();" class=sub>
</td>
</tr>
</form>
<?
} // else ends
?>
</table>
<!--*********** Contents of the Body Ends***************-->
<!--
Javascript for validations & passing the control to HotelAmenities_View along with Pno and passing the control to Search page (Main Menu Page)
-->
<Script Language="Javascript">
function valid1(form)
{
var test = myform.cmbHotelFacility.value;
if (myform.cmbHotelFacility.value == "facility")
{
alert("Select Hotel Facility");
myform.cmbHotelFacility.focus();
return false;
}

if( test.charAt(0) == " ")
{
alert("You Have Entered Space");
myform.txtHotelFacility.value = "";
myform.txtHotelFacility.focus();
return false;
}
var test1=myform.txtHrsofOprn.value;
if(test1.charAt(0)=='!')
{
escape('!');
myform.txtHrsofOprn.focus();
return false;
}

}

function valid()
{
document.myform.action = "HotelAmenities_View.php?Pno=<? print ($pid);?>";
document.myform.submit();
}

function valid2()
{
document.myform.action = "Search.php";
document.myform.submit();
}
</Script>
</td>
</tr>
<tr>
<td height="19">
<!--***********Begins Footer ***************-->

<!--***********Ends Footer ***************-->
</td>
</tr>
</table>
<?
} // Session ends
?>
</body>
</html>
Go to Top of Page
   

- Advertisement -