I use this to display my reps sales and commisions. anyone any idea please... <?php $sql = "SELECT * FROM data WHERE rep='$name' AND status='success'"; $result = mysql_query($sql); while ($record = mysql_fetch_object($result)) { $question = nl2br($record->description); $answer = nl2br($record->answer); ?> <tr class="tdhoverActive" align="left" style="cursor:hand;" onmouseover="this.className='tdhover2Active';" onmouseout="this.className='tdhoverActive';"> <td width="23%" valign="top"> <font class="small"> <div align="center"><?php echo "$record->date";?></a></div></td> <td width="27%" valign="top"> <div align="center"><?php echo "$record->client"; ?></a></div></td> <td width="25%" valign="top"><div align="center"><?php echo "$record->amount"; ?> </div></td> <td width="25%" valign="top"><div align="center"><?php echo "$record->com"; ?> </div></td> <?php } ?> </table> </div> <div align="left"> <p> PHP: Is there a possible way to add a line at the bottom to add up all the sale amounts and commissions?
Just add <td width="25%" valign="top"><div align="center"><?php echo $record->com+$record->amount; ?> </div></td>
that would calculate $amount + $com I need to calculate all the $com displayed and seperately all the $amount
and you didn't show us all the varibles that are $com and all the var's that are $amount. So, do the same thing as they did, but with all the $com amounts and then seperatly with all the $amount var's. Then display them.
Oh, sorry. In that case add before $question = nl2br($record->description); $totalAmount += $record->amount; $totalCommission += $record->com; PHP: And display the values of the variables somewhere outside the loop.
I'm probably doing this all wrong but seems that it could work. my string http://localhost/pnt/admin/?q=new2&name=Gladis PHP: I have list of clients with reps assigned to them. to check if specific rep has clients and add as sale I use this. <?php $sql = "SELECT * FROM clients WHERE rep='$name'"; $result = mysql_query($sql); while ($rep = mysql_fetch_object($result)) { $checkrep = "$record->rep"; } if($rep == "$checkrep") { ?> <form action="?q=new3" method="post"> <table width="347" border="0" align="center"> <tr> <th scope="row"> </th> <td> <?php $sql = "SELECT * FROM clients WHERE rep='$name'"; $result = mysql_query($sql); while ($record = mysql_fetch_object($result)) { ?> <input name="rep" type="text" id="rep" value="<?php echo"$record->rep";?>" /> </tr> <tr> <th scope="row">client</th> <td><select name="client" id="client"> <option value="<?php echo "$record->cname";?>"><?php echo "$record->cname";?></option> </select> </tr> <tr> <th scope="row">amount</th> <td><input name="amount" type="text" id="amount"></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <?php } ?> <b><?php echo "$name has no clients. First add clients to $name 's account"; ?></b> <a href="../index.php?q=client">here</a> <?php } ?> PHP: so if this rep is not assigned to any clients... at the moment it's adding it to reps wheter they have clients or not. <b><?php echo "$name has no clients. First add clients to $name 's account"; ?></b> <a href="../index.php?q=client">here</a> PHP: I probably need else { somewhere.... any ideas?
Both your SQL queries are the same, are you sure its supposed to be that way? What are you actually trying to accomplish here? List all the customer names for a specific rep?
I need a list clients for specific rep ie. Gladis yes. but if Gladis has no clients, it must tell me "Gladis has no clients. First add clients to Gladis 's account". without dispalying the form. If Gladis has clients, it must display the form and not "Gladis has no clients. First add clients to Gladis 's account". like I say, i'm probably dong this all wrong. currently it's working but is adding the "Gladis has no clients. First add clients to Gladis 's account". line, whether the rep has clients or not
Yeah thats more like it.. i usually work on live Databases, but let me see what i can do for you here... ill post back shortly. Please tell me what q=new2 is for?? ,,
Try this and give me your feedback: <?php $name = $_GET['name']; $sql = "SELECT * FROM clients WHERE rep='$name'"; $result = mysql_query($sql); if(!$result) { die(mysql_error()); } $numrows = mysql_num_rows($result); if ($numrows>0) { $i = 0; ?> <form action="?q=new3" method="post"> <table width="347" border="0" align="center"> <?php while($i<=($numrows -1)) { ?> <tr> <th scope="row"> </th> <td> <input name="rep" type="text" id="rep" value="<?php echo"$record->rep";?>" /> </tr> <tr> <th scope="row">client</th> <td><select name="client" id="client"> <option value="<?php echo "$record->cname";?>"><?php echo "$record->cname";?></option> </select> </tr> <tr> <th scope="row">amount</th> <td><input name="amount" type="text" id="amount"></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Submit"></td> </tr> <?php } ?> </table> </form> <?php }else{ ?> <b><?php echo "$name has no clients. First add clients to $name 's account"; ?></b> <a href="../index.php?q=client">here</a> <?php } ?> PHP:
I stand to be corrected, its not working, its duplicating the form for each client. Nope its not working, but don't worry about it too much, I don't really nead the function but here is my client table structure if youd like to take another crack at it. `id` int(10) NOT NULL auto_increment, `cname` varchar(50) default NULL, `number` varchar(20) default NULL, `email` varchar(100) default NULL, `rep` varchar(50) default NULL, `status` varchar(10) default NULL, PRIMARY KEY (`id`)
Ill get back to you with the correct code, can you please give me the SQL query to create the table (not just the structure).
CREATE TABLE `clients` ( `id` int(10) NOT NULL auto_increment, `cname` varchar(50) default NULL, `number` varchar(20) default NULL, `email` varchar(100) default NULL, `rep` varchar(50) default NULL, `status` varchar(10) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Dumping data for table `clients` -- INSERT INTO `clients` (`id`, `cname`, `number`, `email`, `rep`, `status`) VALUES (1, 'Dr Green', '123456789', 'mail@mail.com', 'Gladis', 'processed'), (2, 'Mr Brown', '321654987', 'mail@mail.com', 'Gladis', 'processed'), (3, 'Mrs White', '963258741', 'blom@mail.com', 'Gladis', 'processed'), PHP:
I have to leave right now. I'll get this done for you on Monday.. not sure if that would help.. please leave me a message on this thread if you want me to work on it on Monday.
this app. is for personal use. so I'm not too concerned about it, it was simply an idea I had but I don't have enough knowlege of php. If you could do it, it will be much appreciated. Thanx for your help thus far.
I'm honestly so busy with work, i have numerous projects lined up. If its something your not too concerned about, i guess i should leave this aside. Sorry, but i really have so much work on me.