Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6059363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:42:08+00:00 2026-05-23T08:42:08+00:00

Short version: $count in the code below seems to be 0 even when it

  • 0

Short version:
$count in the code below seems to be 0 even when it shouldn’t, why?

Long version:
The other day my boss said “X has made a program to store schematics in, and released the source code. put this on our intranet” So i got around to figure everything out. The source was about 25 different .php-files and a picture describing database tables and relations. Is the error related to the piece of code below or does it have to do with something else?
Maybe I’m just tired from a long week and just don’t see it.

Code:

    <?php
/**
* new_series.php
*
* Generates all the forms for creating a new series and machinenumbers.
* One form for selecting what drawinglists the serie should contain.
* One form for selecting what drawing the serie should contain and select
* a serienumber.
* One form for selecting machinnumbers.
* One form for listing all drawings with all information and number of
* copies that should be printed.
* This is where the function to automaticly print all drawings should be called
* when that function is availible.
*
* @author Emil Abrahamsson <emil@gavle.to>
*/
if(isset($_REQUEST['list_drw'])){
$info;
for($i=0;$i<20;$i++){
if(isset($_REQUEST['info'.$i]))
$info[$i]=$_REQUEST['info'.$i];
}
$sql1='SELECT * FROM '.TABLE_PREFIX.'drawinglist WHERE
machinetype="'.$_REQUEST['machinetype'].'"';
$result1=mysql_query($sql1,$dbh) or die('sql1: '.mysql_error($dbh));
$drwlists;

$j=0;
while($row1=@mysql_fetch_array($result1,MYSQL_ASSOC)){
foreach($info as $inf){
if($row1['info']==$inf){
$drwlists[$j]=$row1;
$j++;
}
}
}
echo('
<div class="text">
<form name="list_drw" id="list_drw" action="index.php" method="post">
<input type="hidden" name="page" id="page" value="new_series" />
<fieldset style="border:1px solid #783151;width: 355px;height:60px;">
<legend>Ange serienummer och antal:</legend>
<table>
<tr>
<td><label for="series">Serie:</label></td>
<td><input type="text" name="series" id="series" /></td>
<td><label for="quantity">Antal:</label></td>
<td><input type="text" name="quantity" id="quantity" /></td>
</tr>
</table>
</fieldset>
');
$counter=0;
foreach($drwlists as $list){
echo('
<table class="info" width="100%" style="border-bottom:2px solid">
<tr>
<td>Maskintyp: '.$list['machinetype'].'</td>
<td>Info: '.$list['info'].'</td>
<td>Datum: '.$list['date'].'</td>
</tr>
</table>
<table width="100%" style="border-collapse:collapse;text-align:center;" border="1">
<tr>
<td style="width:20px;">&nbsp;</td>
<td style="width:40px;"><label>Ritningsnr</label></td>
<td style="width:15px;"><label>Pos</label></td>
<td style="width:15px;"><label>Rev</label></td>
<td style="width:150px;"><label>Ben&auml;mning</label></td>
<td style="width:20px;"><label>St/m</label></td>
<td style="width:100px;"><label>Anm&auml;rkning</label></td>
</tr>
');
$sql2='SELECT * FROM '.TABLE_PREFIX.'drawinglist_row WHERE
drawinglistID='.$list['drawinglistID'];
$result2=@mysql_query($sql2,$dbh) or die('sql2: '.mysql_error($dbh));
while($row2=@mysql_fetch_array($result2,MYSQL_ASSOC)){
$sql3='SELECT * FROM '.TABLE_PREFIX.'drawings WHERE drawingID="'.$row2['drawingID'].'"
ORDER BY review DESC';
$result3=@mysql_query($sql3,$dbh) or die('sql3: '.mysql_error($dbh));
$row3=@mysql_fetch_array($result3,MYSQL_ASSOC);
echo('
<tr>
<td><input type="checkbox" name="drwlist_rowID[]" id="drwlist_rowID[]"
value="'.$row2['drawinglist_rowID'].'" checked="checked"></td>
<td>'.$row2['drawingID'].'</td>
<td>'.$row2['pos'].'</td>
<td>'.$row3['review'].'</td>
<td>'.$row3['designation'].'</td>
<td>'.$row2['stm'].'</td>
<td>'.$row2['observation'].'</td>
</tr>
');
}
echo('
</table>
');
}
echo('
<table width="100%">
<tr>
<td align="right"><input type="submit" name="new_series" id="new_series"
value="N&auml;sta" /></td>
</tr>

</table>
</form>
</div>
');
}else if(isset($_REQUEST['new_series'])){
//echo('NEW SERIES IS SET');
$count=count($drwlist_rowID);
for($i=0;$i<$_REQUEST['quantity'];$i++){
$sql='INSERT INTO '.TABLE_PREFIX.'series VALUES("'.$_REQUEST['series'].'",'.$_REQUEST['quantity'].', '.($i+1).')';
echo($sql.'</br></br>');
$result=@mysql_query($sql,$dbh) or die('sql: '.mysql_error($dbh));
echo($count);
for($j=0;$j<$count;$j++){
echo($j);
$sql2='INSERT INTO '.TABLE_PREFIX.'machinelist VALUES("'.$drwlist_rowID[$j].'", "'.$_REQUEST['series'].'", '.($i+1).')';
echo($sql2.'</br>');
$result2=@mysql_query($sql2,$dbh) or die('sql2: '.mysql_error($dbh));
}
}
echo('
<div class="text">
<form name="new_series" id="new_series" action="index.php" method="post">
<input type="hidden" name="page" id="page" value="new_series" />
<input type="hidden" name="series" id="series" value="'.$_REQUEST['series'].'" />
<input type="hidden" name="quantity" id="copies" value="'.$_REQUEST['quantity'].'" />
<fieldset style="border:1px solid #783151;width: 200px;">
<legend>Ange maskinnummer:</legend>
<table>
<tr>
<td>Serie</td>
<td>L&ouml;pnummer</td>
<td>Antal</td>
<td>Maskinnummer</td>
</tr>
');
for($i=0;$i<$_REQUEST['quantity'];$i++){
echo('
<tr>
<td>'.$_REQUEST['series'].'</td>
<td><input type="hidden" name="number[]" id="number[]" value="'.($i+1).'"
/>'.($i+1).'</td>
<td>'.$_REQUEST['quantity'].'</td>
<td><input type="text" name="machinenr[]" id="machinenr[]" /></td>
</tr>
');
}
echo('
<tr>
<td colspan="4" align="right"><input type="submit" name="create" id="create"
value="Skapa" /></td>
</table>
</form>
</div>
');
}else if(isset($_REQUEST['create'])){
$count=count($machinenr);
for($i=0;$i<$count;$i++){
if($machinenr[$i]!=''){
$sql='INSERT INTO '.TABLE_PREFIX.'machine VALUES ("'.$machinenr[$i].'",
"'.$_REQUEST['series'].'", '.$_REQUEST['quantity'].', '.$number[$i].')';
$result=@mysql_query($sql,$dbh) or die('sql: '.mysql_error($dbh));
}
}
$sql2 = 'SELECT drawinglist_rowID FROM '.TABLE_PREFIX.'machinelist WHERE
series="'.$_REQUEST['series'].'" GROUP BY drawinglist_rowID';
$result2=@mysql_query($sql2,$dbh) or die('sql2: '.mysql_error($dbh));
echo($sql2.'<br>');
$sql3='SELECT * FROM '.TABLE_PREFIX.'drawinglist_row WHERE drawinglist_rowID='.@mysql_result($result2,0,'drawinglist_rowID');
echo($sql3.'<br>');
$result3=@mysql_query($sql3,$dbh) or die('sql3: '.mysql_error($dbh));
$sql4='SELECT machinetype FROM '.TABLE_PREFIX.'drawinglist WHERE
drawinglistID='.@mysql_result($result3,0,'drawinglistID');
$result4=@mysql_query($sql4,$dbh) or die('sql4: '.mysql_error($dbh));
echo('
<div class="text">
<form name="print_drw" id="print_drw action="index.php" method="post">
<input type="hidden" name="page" id="page" value="new_series" />
<table class="info" width="100%" style="border-bottom:2px solid">
<tr>
<td>Maskintyp: '.@mysql_result($result4,0,'machinetype').'</td>
</tr>

</table>
<table width="100%" style="border-collapse:collapse;text-align:center;" border="1">
<tr>
<td style="width:40px;"><label>Ritningsnr</label></td>
<td style="width:15px;"><label>Pos</label></td>
<td style="width:15px;"><label>Rev</label></td>
<td style="width:150px;"><label>Ben&auml;mning</label></td>
<td style="width:20px;"><label>St/m</label></td>
<td style="width:100px;"><label>Anm&auml;rkning</label></td>
<td style="width:40px;"><label>PDF</label></td>
<td style="width:50px;"><label>Utskr. ant.</label></td>
</tr>
');
while($row2=@mysql_fetch_array($result2,MYSQL_ASSOC)){
$sql5='SELECT * FROM '.TABLE_PREFIX.'drawinglist_row WHERE
drawinglist_rowID='.$row2['drawinglist_rowID'];
$result5=@mysql_query($sql5,$dbh) or die('sql5: '.mysql_error($dbh));
$row5=@mysql_fetch_array($result5,MYSQL_ASSOC);
$sql6='SELECT designation, review FROM '.TABLE_PREFIX.'drawings WHERE
drawingID="'.$row5['drawingID'].'" ORDER BY review DESC';
$result6=@mysql_query($sql6, $dbh) or die('sql6: '.mysql_error($dbh));
$row6=@mysql_fetch_array($result6,MYSQL_ASSOC);
$type=substr(preg_replace("/[^0-9]/", '', $row5['drawingID']),0,1);
$no;
switch($type){
case '1':
case '2':
$no=4;
break;
case '3':
case '4'
:$no=3;
break;
}
echo('
<tr>
<td>'.$row5['drawingID'].'</td>
<td>'.$row5['pos'].'</td>
<td>'.$row6['review'].'</td>
<td>'.$row6['designation'].'</td>
<td>'.$row5['stm'].'</td>
<td>'.$row5['observation'].'</td>
<td>
');
$url= DRW_PATH.$row5['drawingID'].strtolower($row6['review']).'.pdf';
if(file_exists($url))
echo('<a href="'.$url.'" target="_blank">PDF</a><input type="hidden" name="url[]"
id="url[]" value="'.$url.'" />');
echo('
</td>
<td><input type="text" name="copies[]" id="copies[]" size="2" style="text-
align:center;" value="'.$no.'"/></td>
</tr>
');
}
/* Not functional yet */
/*
echo('
</table>
<table width="100%">
<tr>
<td align="right"><input type="submit" name="print" id="print" value="Skriv ut"
/></td>
</tr>
</table>
</form>
</div>
');
*/
echo('
</table>
</form>
</div>
');
}else{
$sql1='SELECT info FROM '.TABLE_PREFIX.'drawinglist WHERE
machinetype="'.$_REQUEST['machinetype'].'" GROUP BY info';

$result1=@mysql_query($sql1,$dbh) or die ('sql1: '.mysql_error($dbh));
echo('
<div class="text">
<form name="new_serie" id="new_serie" action="index.php" method="post">
<input type="hidden" name="page" id="page" value="new_series" />
<input type="hidden" name="machinetype" id="machinetype"
value="'.$_REQUEST['machinetype'].'" />
<table>
<tr>
<td colspan="2" class="machinetype">'.$_REQUEST['machinetype'].'</td>
</tr>
');
$j=0;
while($row1=@mysql_fetch_array($result1,MYSQL_ASSOC)){
echo('
<tr>
<td><font style="font-family:Verdana, sans-serif;font-size:14px;color:#000000;line-
height:25px;">'.$row1['info'].'</font></td>
<td><input type="checkbox" name="info'.$j.'" id="info'.$j.'" value="'.$row1['info'].'"
/></td>
</tr>
');
$j++;
}
echo('
<tr>
<td colspan="2" align="right"><input type="submit" name="list_drw" id="list_drw"
value="N&auml;sta" /></td>
</tr>
</table>
</form>
</div>
');
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:42:08+00:00Added an answer on May 23, 2026 at 8:42 am
    112: $count=count($drwlist_rowID);
    

    What is $drwlist_rowID? It seems not to be defined…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is the short version of my code, it's very basic. In my page
Short version: assuming I don't want to keep the data for long, how do
Short version: I want to trigger the Form_Load() event without making the form visible.
Short version: I'm wondering if it's possible, and how best, to utilise CPU specific
Short Version: When I've created a Channel using ChannelFactory on a client which uses
I am writing an application to manage user access to files. The short version
Short: how does modelbinding pass objects from view to controller? Long: First, based on
Short Version For those who don't have the time to read my reasoning for
Short Version I want an ADPlus script that will do a full memory dump
Short version: I want a way to run somefunction(username) and have it return the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.