Jump to content

jonnyuk3

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jonnyuk3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks guys, I've been stuck on that all morning!!
  2. hi blacknight, thanks for the reply. yes, the form will be expanded later. I just need to get this working first. I tried what you suggested and it still doesn't work!! This is where I added the code, is this correct?? echo "<p>Location: "; echo "<select name='location'>"; while(($row = mysql_fetch_array($result))) { echo "<option value='{$row['location_id']}"; //Default value if(isset($_POST['location']) && $row['location_id'] == $_POST['location']) echo " selected "; echo "'>{$row['location_name']}</option>\n"; } echo "</select>";
  3. Hi all, I have a listbox on a form that gets it's data from a MySQL query, all of which is working fine. I make a selection in my listbox and then submit the form which is reloading itself. However on the reload I would like the listbox to display the selection made by the user, instead it reverts to the first item in the list. I have included the code, if someone could point me in the right direction that would be great. I have searched these forums and tried a few things that are suggested but I still can't get it to work. <?php include("dbconn.php"); $query = "SELECT location.location_name, printer.model_number, location_printer.serial_number" . " FROM location, printer, location_printer" . " WHERE location.location_id = location_printer.location_id" . " AND printer.printer_id = location_printer.printer_id"; $result = mysql_query($query); echo "<table>"; echo "<th>Location</th>"; echo "<th>Printer</th>"; echo "<th>Serial No</th>"; while(($row = mysql_fetch_array($result))) { echo "<tr>"; echo "<td>".$row['location_name']."</td>"; echo "<td>".$row['model_number']."</td>"; echo "<td>".$row['serial_number']."</td>"; echo "</tr>"; } echo "</table>"; if(isset($_POST['location'])) { $loc = $_POST['location']; echo "<p>Location = <b> $loc </b>"; } ?> <html> <head> <title>Loop Results</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <table> <tr> <td> <?php $query = "SELECT * FROM location ORDER BY location_name"; $result = mysql_query($query); $default = $_POST['location']; echo "<p>Location: "; echo "<select name='location'>"; while(($row = mysql_fetch_array($result))) { echo "<option value='{$row['location_id']}"; //Selected value if($row['location_id'] == $default) echo " selected "; echo "'>{$row['location_name']}</option>\n"; } echo "</select>"; ?> </td> </tr> <tr> <td> <input type="submit" /> </td> </tr> </table> </form> </body> </html>
  4. Hi, I'm not sure if this is possible but hoping someone in here will say it is and show me how. I have a list of suplliers returned from my database, fields include: account name address 1 address 2 post code and region. I would like to split the data into multiple tables by region and have a header on each table with the region name. This is what i currently have, but that just shows each supplier in one long table. $query = "SELECT * FROM product_stockist WHERE $cat='Y' ORDER BY Region"; $result = mysql_query($query); $no_of_rows = mysql_num_rows($result); if($no_of_rows > 0){ echo "<table width=100% align=center callpadding=2 cellspacing=0>"; echo "</tr>"; } while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr>"; echo "<td>{$row['Account_Name']} </td>". "<td>{$row['Address_Line_1']} </td>". "<td>{$row['Address_Line_2']} </td>". "<td>{$row['Address_Line_4']} </td>". "<td>{$row['Post_Code']} </td>". "<td>{$row['Region']} </td>"; echo "</tr>"; } echo "</table";
×
×
  • 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.