Jump to content

bajangerry

Members
  • Posts

    53
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

bajangerry's Achievements

Member

Member (2/5)

0

Reputation

  1. Pikachu2000, You and me are together in that boat, thanks for the help anyway.
  2. Pikachu, I do actually have a reason for the table being inside the while loop and I know it is causing the problems I have by being there. I will eventually have a sub-table showing dependents for this initial table under each of the rows so I will need the header row for each in this configuration. I guess what I would ideally like to achieve is to force the initial table columns to be a set % size of the row but I am not sure how best to do this.
  3. Thanks New Coder, I tried your code and it worked great but I am trying to get it to work using the CSS alone and I still don't seem to be able to get that to work for some reason. Will keep digging at it! Thanks again.
  4. Hi Guys, I have a query and a while loop output that I am sending to a webpage in a table format but I need some help in how best to do this so that the table columns line up with each other. Right now the column width seems to change depending on the data in the row. The code is quite simple: <?php include("lib/config.php"); $query = "SELECT * FROM staff_member"; $result = mysql_query($query); ?> <html> <style type="text/css"> <!-- @import url(style/style.css); --> </style> <head> </head> <body> <h2 align="center"> Full Staff list with Dependants</font></h2> <?php while($row = mysql_fetch_object($result)) { echo "<table id=sample> <th>Title</th> <th>First Name</th> <th>Initial</th> <th>Last</th> <th>Agency</th> <th>Street</th> <th>Address</th> <th>Parish</th> <th>Country</th> <th>Office Tel#</th> <th>Home Tel#</th> <th>Office Mobile#</th> <th>Personal Mobile#</th> <th>Zone</th> <th>Status</th> <th>Location</th> <th>Updated by</th> <tr> <td>" .$row->title ."</td> <td>" .$row->first ."</td> <td>" .$row->initial ."</td> <td>" .$row->last ."</td> <td>" .$row->agency ."</td> <td>" .$row->street ."</td> <td>" .$row->adress ."</td> <td>" .$row->parish ."</td> <td>" .$row->country ."</td> <td>" .$row->officetel ."</td> <td>" .$row->hometel ."</td> <td>" .$row->officemobile ."</td> <td>" .$row->personalmobile ."</td> <td>" .$row->zone ."</td> <td>" .$row->status ."</td> <td>" .$row->location ."</td> <td>" .$row->updater ."</td> </tr>"; echo "</table> </br>"; }//close $row while ?> </body> </html> Any help appreciated!
  5. Guys, I have a project that I am starting to work on that I have a question about before I actually start creating my query for. What I would be doing is have dropdown menu boxes providing selections from a table and then an box for entering search parameters next to this box. i.e. the table will have in things like Name, Address, Telephone, Age etc which will be selectable in the dropdown menu box and then the user would enter a search parameter that relates to the selection in the other box. All this I know how to do and have done in the past but what I am hoping to be able to do is this: Every time a selection is made in a dropdown menu another one should appear under that one to allow the user to select another search parameter if the wish to reduce the number of results. I do not want to fill the page with all the table's available options as there will be a large number but would rather bring up a new pair of boxes for them to use if they wish. Any ideas? Can this actually be done in PHP or would I need to use something like Java to achieve this? I am not sure how to get the interaction from the page to provide the new boxes without sending the page each time. Thanks for any suggestions here.
  6. Thanks Goat and schilly, it works great now, have learnt a lot from this process.
  7. That's it Goat!!! Thank you it is working now I think, will do a few more check and confirm in a minute or two
  8. Ok, did that so that the output from my " print_r($_POST);" give me: Array ( [accode] => Array ( [1] => 99999 [2] => 12345 ) [id] => Array ( [1] => 1 [2] => 2 ) [send] => Update ) which actually updates the first row in the table but not the second for some reason. I have the following: if(isset($_POST['send'])) { for($counter = 0; $counter < sizeof($_POST['accode']); $counter++) { $update = "UPDATE mobile SET accountcode='".$_POST['accode'][$counter]."' WHERE id ='".$_POST['id'][$counter]."' "; $result = mysql_query($update) or die(mysql_error()); //flush(); } } Any suggestion as to why the second row does not get updated?
  9. Sorry goat but I am not totally confused by whatyou mean in your last post :confused "Add [] in accode input name"... where exactly do you mean? I got the output printing with the print_r($_POST); and I can see data is being passed but still not getting it into the table... :
  10. Goat, I added a primary key to the table (mysql will allow you to create table with no indexes although why you would do so I do not know) as a column called "id" which will auto increment. I still am not getting the results I expect though, even when I echo the count value I get nothing showing up: <?php include "lib/config.php"; top(); $no=$_GET['no']; if(isset($_POST['send'])) { for($counter = 0; $counter < sizeof($_POST['accode']); $counter++) { echo "size of array = ".sizeof($_POST['accode'])."<br>"; $update = "UPDATE mobile SET accountcode='".$_POST['accode'][$counter]."' WHERE id ='".$_POST['id'][$counter]."' "; $result = mysql_query($update) or die(mysql_error()); //flush(); } } ?> <html> <head> <title>Mobile Calls</title> <style type="text/css"> </style> </head> <html> <body> <br> <div align="center"> <font size = "3" color="#FF0000"><strong>Calls made by Mobile Number: <?echo ($no)?> </strong></font></div><br> <form name="test" method="post"> <table id="printTable" border="1" id="mobilenumbers"> <tr> <td nowrap><div align="center"> <font size="3"><strong>Date</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Location</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Called No</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>System Time</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Length</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Type</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Cost</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Account Code</strong></font></div></td> </tr> <? $result = mysql_query("SELECT * FROM mobile WHERE `service` = '$no'"); $count += 0; while ($row = mysql_fetch_object($result)){ $count += 1; ?> <td><div align="center"><font size="3"><? echo($row->date);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->location);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->dialed);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->time);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->duration);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->type); ?></font></div></td> <td><div align="center"><font size="3"><?php echo "$"?><?php echo number_format($row->cost, 2, '.', '.');?></font></div></td> <td><div align="center"><input name="accode<? echo $count;?>" type="text" id="accode" size="6"value=<?php echo ($row->accountcode);?>></font></div></td> <input type="hidden" name="id" value="<?php echo $row->id?>"> </tr> <? } ?> </table> <br> <input name="send" type="submit" value="Update"> </form> </body> </html>
  11. Goat, My problem here is ensuring that the update is applied to the correct row in the table which does NOT have a unique identifier(stupid I know, but I inherited it this way). So I am hoping to send multiple fields so that the update query will be able to use them to confirm that the row is the correct one to update. That being the case I am having a problem understanding how I can get these multiple fields back out of the array with the FOREACH to be able to use them in the update query. This is what I have so far now with the update query commented out and the foreach results echoed to screen. <?php include "lib/config.php"; top(); $no=$_GET['no']; if(isset($_POST['send'])) { foreach($_POST as $key=>$value) { echo $key.": ". $value; echo "<br>"; //$update = "UPDATE mobile SET accountcode = '$code' WHERE dialed = '$dialed' AND location = '$location' AND date = '$date' AND time = '$time' AND duration = '$duration'"; //$result = mysql_query($update) or die(mysql_error()); //flush(); } } ?> <html> <head> <title>Mobile Calls</title> <style type="text/css"> </style> </head> <html> <body> <br> <div align="center"> <font size = "3" color="#FF0000"><strong>Calls made by Mobile Number: <?echo ($no)?> </strong></font></div><br> <form name="test" method="post"> <table id="printTable" border="1" id="mobilenumbers"> <tr> <td nowrap><div align="center"> <font size="3"><strong>Date</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Location</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Called No</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>System Time</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Length</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Type</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Cost</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Account Code</strong></font></div></td> </tr> <? $result = mysql_query("SELECT * FROM mobile WHERE `service` = '$no'"); $count += 0; while ($row = mysql_fetch_object($result)){ $count += 1; ?> <td><div align="center"><font size="3"><? echo($row->date);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->location);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->dialed);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->time);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->duration);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->type); ?></font></div></td> <td><div align="center"><font size="3"><?php echo "$"?><?php echo number_format($row->cost, 2, '.', '.');?></font></div></td> <td><div align="center"><input name="accode<? echo $count;?>" type="text" id="accode" size="6"value=<?php echo ($row->accountcode);?>></font></div></td> <input type="hidden" name="count<? echo $count;?>" value="<?php echo $count?>"> <input type="hidden" name="date<? echo $count;?>" value="<?php echo ($row->date)?>"> <input type="hidden" name="location<? echo $count;?>" value="<?php echo ($row->location)?>"> <input type="hidden" name="dialed<? echo $count;?>" value="<?php echo ($row->dialed)?>"> <input type="hidden" name="time<? echo $count;?>" value="<?php echo ($row->time)?>"> <input type="hidden" name="duration<? echo $count;?>" value="<?php echo ($row->duration)?>"> </tr> <? } ?> </table> <br> <input name="send" type="submit" value="Update"> </form> </body> </html>
  12. schilly, I think I need some further help with this as I am having trouble figuring out how to "cycle" through the post array, can you explain what you mean by that? I have got this working if I have one entry in the table and I can update the field fine that way but once there are more than one row in teh table I am having a problem.
  13. Thanks schilly, that makes sense so I will give that a try and let you know how it goes.
  14. Hi Guys, I need some help here understanding how best to update multiple rows in a table at once. I have a table which displays a number of columns, one of which I need to have the users enter some data in and when they have completed all the rows then they should click a button and the database table should be updated with the new data. I am stumped as to how to achieve this multiple row update at once. The code I have so far simple displays the data and I can not figure out where to go from here: Any help gratefully accepted! <?php include "lib/config.php"; top(); $no=$_GET['no']; ?> <html> <head> <title>Mobile Calls</title> <style type="text/css"> </style> </head> <body> <br> <div align="center"> <font size = "3" color="#FF0000"><strong>Calls made by Mobile Number: <?echo ($no)?> </strong></font></div><br> <table id="printTable" border="1" id="mobilenumbers"> <tr> <td nowrap><div align="center"> <font size="3"><strong>Date</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Location</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Called No</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>System Time</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Length</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Type</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Call Cost</strong></font></div></td> <td nowrap><div align="center"> <font size="3"><strong>Account Code</strong></font></div></td> </tr> <? $result = mysql_query("SELECT * FROM mobile WHERE `service` = '$no'"); while ($row = mysql_fetch_object($result)){ ?> <td><div align="center"><font size="3"><? echo($row->date);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->location);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->dialed);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->time);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->duration);?></font></div></td> <td><div align="center"><font size="3"><?php echo ($row->type); ?></font></div></td> <td><div align="center"><font size="3"><?php echo "$"?><?php echo number_format($row->cost, 2, '.', '.');?></font></div></td> <td><div align="center"><input name="accode" type="text" id="accode" size="6"value=<?php echo ($row->accountcode);?>></font></div></td> </tr> <? } ?> </table> </body> </html>
  15. ok, figured out that the values would be in seconds, hence 120 is 2 minutes so I can use "TIMEDIFF(unlime.time, import.time) BETWEEN -120 and 120" to test for results within a minute of each other. I am seeing light at the end of the tunnel, thanks for your help TeNDoLLA.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.