473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem with printing array values

I have an array of values that come from a database.

I used a FOR loop to retrieve each of the values and pass it on to text fields. But the instead of displaying the whole word, only the first letter of the values get displayed and it doesn't even pass the values.

[PHP]
<?
$desc_array = count($part_desc);
for($x=0; $x<=$desc_array; $x++)
{
?>
self.opener.document.form1.particles[<?=$x?>].value=<?echo "$part_desc[x]";?>;
<?}?>
[/PHP]

could you in any way improve my code so that it would work? I really need a solution for this. I need to present my program tomorrow afternoon. This is the only problem that some how I couldn't fix. I was actually able to make it work by chance yesterday but I accidentally pressed the shutdown button on my keyboard. It is dangerously beside the enter key.
Feb 14 '08 #1
6 1585
ronverdonk
4,258 Expert 4TB
Statement 6 should have the $x instead of the x:
[php]$part_desc[$x][/php]
Ronald
Feb 14 '08 #2
Statement 6 should have the $x instead of the x:
[php]$part_desc[$x][/php]
Ronald
Thanks for the reply. But the thing is, it still didn't work.

For some reason, it just broke apart the array values and displayed the letter of the value where the position is $x.
Feb 14 '08 #3
ronverdonk
4,258 Expert 4TB
Should "$part_desc[x]"; not be enclosed within quotes? If so, the statement should be:
[php]
self.opener.document.form1.particles[<?=$x?>].value=<?echo "'".$part_desc[$x]."'";?>;
[/php]
Ronald
Feb 14 '08 #4
Should "$part_desc[x]"; not be enclosed within quotes? If so, the statement should be:
[php]
self.opener.document.form1.particles[<?=$x?>].value=<?echo "'".$part_desc[$x]."'";?>;
[/php]
Ronald
Still no luck. Didn't work as well. I forgot to mention that the for loop is inside another for loop.
Feb 14 '08 #5
ronverdonk
4,258 Expert 4TB
Still no luck. Didn't work as well. I forgot to mention that the for loop is inside another for loop.
Well, the part I showed you works (I tested that).
Since you mention another loop, maybe it is time to show all code.

Ronald
Feb 14 '08 #6
[PHP]<?
include("conn_db.php");
?>
<html>
<head>
<title>Customers</title>
<link href="css/format.css" rel="stylesheet" type="text/css">
</head>

<body>
<form name="form">
<table width="136" border="1">
<tr>
<td width="126"><table width="126" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="126" align="center" bgcolor="#FF0000" class="header">Dealers / Corporate</td>
</tr>
<tr>
<td align="center">
<?
$code = mysql_query ("SELECT so.so_no, fs.form_status as status, ct.cust_type as customer_type, so.cust_id,
c.company as customer, c.tin, c.contact, c.address, cy.name as city, p.name as province,
c.area_code, c.phone_no, c.fax_no, c.mobile_no, c.email, pr.description as product,
so.serial_no, pc.prod_cat as product_category, pr.model_no, pa.part_desc as part_desc, sp.qty, m.description, sm.qty,
u.username as prepared_by, t.last_name as tlname, t.first_name as tfname, t.middle_name as tmname,
u.username as costing_approved, labor, spare_parts, materials, total_charges
FROM service_order as so
LEFT JOIN forms_status as fs ON fs.form_status_id = so.status
LEFT JOIN customer_type as ct ON ct.cust_type_id = so.cust_type_id
LEFT JOIN customer as c ON c.cust_id = so.cust_id
LEFT JOIN city as cy ON cy.city_id = c.city_id
LEFT JOIN province as p ON p.province_id = c.province_id
LEFT JOIN product as pr ON pr.prod_id = so.prod_id
LEFT JOIN product_category as pc ON pc.code_cat = pr.code_cat
INNER JOIN so_parts AS sp ON so.so_no = sp.so_no
LEFT JOIN parts AS pa ON pa.part_id = sp.part_id
INNER JOIN so_materials AS sm ON so.so_no = sm.so_no AND sp.parts_so_id = sm.parts_so_id
LEFT JOIN material AS m ON m.material_id = sm.mat_id
LEFT JOIN user as u ON u.user_id = so.prepared_by
LEFT JOIN technician as t ON t.tech_id = so.service_tech
WHERE so.cust_id != 'NULL' AND ct.cust_type_id = '2'");
?>
<select name="customers" size="10" class="txtreq" onChange="goCorDeal()" style="width:125px">
<?
while($row = mysql_fetch_array($code))
{
$so_no = $row["so_no"];
$cust_id = $row["cust_id"];
$company = $row["customer"];
$tin = $row["tin"];
$contact = $row["contact"];
$address = $row["address"];
$city = $row["city"];
$province = $row["province"];
$areacode = $row["area_code"];
$phone = $row["phone_no"];
$areacode2 = $areacode;
$fax = $row["fax_no"];
$mobile = $row["mobile_no"];
$email = $row["email"];
$prod_id = $row["prod_id"];
$product = $row["product"];
$category = $row["product_category"];
$serial = $row["serial_no"];
$model = $row["model_no"];
$prepared_by = $row["user"];
$costing_approved = $row["user"];
$tlname = $row["tlname"];
$tfname = $row["tfname"];
$tmname = $row["tmname"];
$technician = $tlname.", ".$tfname." ".$tmname;
$labor = $row["labor"];
$spare_parts = $row["spare_parts"];
$materials = $row["materials"];
$total_charges = $row["total_charges"];
$part_desc = $row["part_desc"];

print "<option value='$so_no`$cust_id`$company`$tin`$contact`$add ress`$city`$province`$areacode`$phone`$areacode2`$ fax`$mobile`$email`$prod_id`$product`$category`$se rial`$model`$labor`$spare_parts`$materials`$total_ charges`$part_desc'>SO №: ".$so_no."</option>\n";
?>
<script type="text/javascript">
function goCorDeal()
{
var names = document.form.customers.options[document.form.customers.selectedIndex].value;
var temp = new Array();
temp = names.split('`');

for(i=0;i<='<?=$so_no?>';i++)
{
self.opener.document.form1.so_no.value = temp[0];
self.opener.document.form1.cust_id.value = temp[1];
self.opener.document.form1.company.value = temp[2];
self.opener.document.form1.tin.value = temp[3];
self.opener.document.form1.contactperson.value = temp[4];
self.opener.document.form1.address.value = temp[5];
self.opener.document.form1.city.value = temp[6];
self.opener.document.form1.province.value = temp[7];
self.opener.document.form1.areacode.value = temp[8];
self.opener.document.form1.phone.value = temp[9];
self.opener.document.form1.areacode2.value = temp[10];
self.opener.document.form1.fax.value = temp[11];
self.opener.document.form1.mobile.value = temp[12];
self.opener.document.form1.email.value = temp[13];
self.opener.document.form1.prod_id.value = temp[14];
self.opener.document.form1.product.value = temp[15];
self.opener.document.form1.category.value = temp[16];
self.opener.document.form1.serial.value = temp[17];
self.opener.document.form1.model.value = temp[18];
self.opener.document.form1.labor.value = temp[19];
self.opener.document.form1.spareparts.value = temp[20];
self.opener.document.form1.materials.value = temp[21];
self.opener.document.form1.total_charges.value = temp[22];
}
<?
$desc_array = count($part_desc);
for($x=0; $x<=$desc_array; $x++)
{?>
self.opener.document.form1.particles[<?=$x;?>].value=<?echo $part_desc[$x];?>;
<?
}?>
window.close();
}
</script>
<?
}
?>
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>[/PHP]

here's the complete code.
Feb 14 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem...
0
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
7
by: crazy | last post by:
Hi It seems something really simple, but can't figure out. It's not my homework :), was just looking at some C problems on the web and came across this one. why doesn't the following code print...
3
by: ritchie | last post by:
Hi all! Still working on this program! Just to recap, I am writing a program to sort an array with four different sort algorythms. I am having a little trouble at the moment though! Now, I...
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
0
by: mottebelke | last post by:
I want to print a bitmap directly to a network printer using a socket. To do this I use PCL codes to set the printer in the right mode and print the image. Note that this code is used on the...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
2
by: Latina | last post by:
Hi, Can some one help to figure out why is only printing '{ }' and not the values the user is entering? Here is part of my code: void IntegerSet::setString() { cout<<"{"; for(element=0;...
5
Kelicula
by: Kelicula | last post by:
Hello all. I have a problem which seems to make no sense to me. Therefore I must be doing something wrong. I am trying to populate an array using split with a regexe. Here is the code (snippet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.