Jump to content

uwictech

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by uwictech

  1. Hi all, On the Home page of a website that I have designed, I would like to show parts of other websites. The other websites contain information such as health monitors for different parts of the network. Another website may contain the temperatures in the server rooms. I would like to pull these all together on my home page like little port lets. Is this possible with PHP, or would something like java scrip be more useful? Jamie
  2. I thought it may have been the &, thanks Pete. If I wanted to put that inside an HTML button, is that possible? Jamie
  3. Thanks Sasa, that worked brilliantly!!! One more thing if possible? I have set up dynamaic pages so that if someone clicks on a link to go to the udf search page the url looks like this http://localhost/index1.php?page=udfsearch When I setup the next buttons they obviously run on the same page, at the moment the link is set up run on my test page which is called qqq so the link is <a href='qqq.php?udf=$udfin&start=$next'>Next</a>"; If I want it to run on my dynamic page what do I change the link to? Jamie
  4. Thanks for your input Pete. I think I have been looking at this to long, it's taken up so much of my time, I'm willing to give anything to get this to work! I have made some changes, I don't this they are correct as its defaulting to the default number given in the, if else statement at the top of my code when I press the next button. I know I useless at this guy's, I can't tell you how much I would appreciate it if someone could help me further. Jamie <?php require("conf.php"); //max displayed per page $per_page = 5; //get start variable $start = $_GET['start']; if(isset($_POST['udf'])) { $udfin = $_POST['udf']; } elseif(isset($_GET['udf'])) { $udfin = $_GET['udf']; } else { $udfin = 1; } //count records $record_count = mysql_num_rows(mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin")); //count max pages $max_pages = $record_count / $per_page; //may come out as decimal if (!$start) $start = 0; //display data $get = mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) { // get data $id = $row['id']; $ext = $row['ext']; $equ = $row['equ']; $udf = $row['udf']; $udf1 = $row['udf1']; $udf2 = $row['udf2']; echo " ID (".$id.") EXT (".$ext.") EQU (".$equ.") UDF (".$udf.") UDF1 (".$udf1.") UDF2 (".$udf2.")<br />"; } //setup prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show next button if (!($start>=$record_count-$per_page)) echo " <a href='qqq.php?udf=1&start=2'>Next</a>"; //show prev button if (!($start<=0)) echo "<a href='qqq.php?udf=1&start=2'>Prev</a> "; //show page numbers //set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='qqq.php?start=$x'>$i</a> "; else echo " <a href='qqq.php?start=$x'><b>$i</b></a> "; $i++; } ?> <h3> UDF Query </h3> <form name="form1" method="post" action="http://localhost/qqq.php"> <p> Input UDF: <input type="number" name="udf" value= "<?php echo $udfin; ?>" size="1" maxlength="4"/></p><br> <p> Q = <font color="red"><?php echo $id; ?> </font> </p> <p> EXT = <font color="red"><?php echo $ext; ?> </font> </p> <p> EQU = <font color="red"><?php echo $equ; ?> </font></p> <p> UDF = <font color="red"><?php echo $udf; ?> </font></p> <p> UDF2 = <font color="red"><?php echo $udf2; ?> </font></p> <p> UDF3 = <font color="red"><?php echo $udf3; ?> </font></p> <p><input type="submit" name="submit" value="GET DATA"/></p> </form>
  5. Hi both, thanks for your replies. The URL i am passing is <a href='qqq.php?start=2'>Next</a> I'm just getting myself confused!
  6. Hi All, I think I'm finally getting somewhere with pagination! I can now submit a query and get the correct number of records back with the correct number of pages. My only problem is, when I press the page numbers or the next button the records disappear. If anyone gets time, could you take a look at my code and tell me where I’m going wrong please? Jamie <?php require("conf.php"); //max displayed per page $per_page = 2; //get start variable $start = $_GET['start']; $udfin = $_POST['udf']; //count records $record_count = mysql_num_rows(mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin")); //count max pages $max_pages = $record_count / $per_page; //may come out as decimal if (!$start) $start = 0; //display data $get = mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) { // get data $id = $row['id']; $ext = $row['ext']; $equ = $row['equ']; echo $id." (".$ext.") (".$equ.")<br />"; } //setup prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show prev button if (!($start<=0)) echo "<a href='qqq.php?start=$prev'>Prev</a> "; //show page numbers //set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='qqq.php?start=$x'>$i</a> "; else echo " <a href='qqq.php?start=$x'><b>$i</b></a> "; $i++; } //show next button if (!($start>=$record_count-$per_page)) echo " <a href='qqq.php?start=$next'>Next</a>"; ?> <h3> UDF Query </h3> <form name="form1" method="post" action="http://localhost/qqq.php"> <p> Input UDF: <input type="number" name="udf" value= "<?php echo $udfin; ?>" size="1" maxlength="4"/></p><br> <p><input type="submit" name="submit" value="GET DATA"/></p> </form>
  7. Hi, My apologies if I have not explained myself properly. Hopefully, this will tell you exactly what I am trying to convey. I would like to search the database for a specific number (UDF), there could be more than one record that comes back. I would then like to be able to cycle through those records. Is that enough info? Jamie
  8. Hi, Thanks for the reply. I'm sorry, I just don't know what to do with this function. I was hoping for a bit of advice on what I have to do with my code. Hope someone can help. Jamie
  9. Thanks for that GK. I did some searching and changed my code. I can now cycle through every record but, I can no longer search for a record. When I press the "GET DATA" button nothing happens. I would like to press the "GET DATA" button and then cycle through the records that come back. I will try and fix it myself, but any help would be appreciated. <?php //run ext query require("conf.php"); { $udf_form = $_POST['udf']; $extract = mysql_query ("SELECT * FROM cy_equ WHERE udf = '$udf_form' LIMIT 1 "); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $equ = $row['equ']; $ext = $row['ext']; $udf = $row['udf']; $udf2 = $row['udf2']; $udf3 = $row['udf3']; } } if(isset($_POST['next'])) { $udf_form = $_POST['udf'] + 1; } elseif(isset($_POST['prev'])) { $udf_form = $_POST['udf'] - 1; } else { // something else } ?> <div class="boxextqry"> <h3> UDF Query </h3> <form name="form1" method="post" action="../index1.php?page=udfsearch"> <p> Input UDF: <input type="number" name="udf" size="1" maxlength="4"/></p><br> <p> ID = <font color="red"><?php echo $id; ?> </font> </p> <p> EXT = <font color="red"><?php echo $ext; ?> </font> </p> <p> EQU = <font color="red"><?php echo $equ; ?> </font></p> <p> UDF = <font color="red"><?php echo $udf; ?> </font></p> <p> UDF2 = <font color="red"><?php echo $udf2; ?> </font></p> <p> UDF3 = <font color="red"><?php echo $udf3; ?> </font></p> <p><input type="submit" name="submit" value="GET DATA"/></p> <input type="hidden" name="udf" value= "<?php echo $udf_form; ?>" /> <p><input type="submit" name="next" value="NEXT"/></p> <p><input type="submit" name="prev" value="PREV"/></p> </form> </div>
  10. Hi all, Sorry if this is simple, i'm very new to php, well, any programming language actually. My code runs a query and comes back with the results. Very rarely there may be more than one result. I have added the code that I think should enable me to go to the next and previous records but it is not working. I have tried lots of different bits of code so now its all over the shop! Can you help please? Jamie <?php //run ext query require("conf.php"); { $udf_form = $_POST['udf']; $extract = mysql_query ("SELECT * FROM cy_equ WHERE udf = '$udf_form' LIMIT 1 "); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $equ = $row['equ']; $ext = $row['ext']; $udf = $row['udf']; $udf2 = $row['udf2']; $udf3 = $row['udf3']; $next = $udf + 1; $prev = $udf - 1; } } $next = $udf_form + 1; $prev = $udf_form - 1; ?> <div class="boxextqry"> <h3> UDF Query </h3> <form name="form1" method="post" action="../index1.php?page=udfsearch"> <p> Input UDF: <input type="number" name="udf" size="1" maxlength="4"/></p><br> <p> ID = <font color="red"><?php echo $id; ?> </font> </p> <p> EXT = <font color="red"><?php echo $ext; ?> </font> </p> <p> EQU = <font color="red"><?php echo $equ; ?> </font></p> <p> UDF = <font color="red"><?php echo $udf; ?> </font></p> <p> UDF2 = <font color="red"><?php echo $udf2; ?> </font></p> <p> UDF3 = <font color="red"><?php echo $udf3; ?> </font></p> <p><input type="submit" name="submit" value="GET DATA"/></p> <p><input type="submit" name="udf[<?php echo $next?>]" value="NEXT"/></p> <p><input type="submit" name="udf[<?php echo $prev?>]" value="PREV"/></p> </form> </div>
  11. Sorry, Basically, I can search for information and display the results into input boxes. I would then like to maniplulate that data and click an update button to update the database. Here is the code I currently have:- <div class="boxextupdate"> <h3> Ext Update </h3> <form name="form5" method="post" action="../index1.php?page=tele"> <p> Input Ext: <input type="number" name="ext" size="1" maxlength="4"/></p><br> <p> Ext: <input type="number" name="extupdate" value="<?php echo $extupdate; ?>" size="1" maxlength="4"/></p> <p> EQU: <input type="number" name="equupdate" value="<?php echo $equupdate; ?>" size="8" maxlength="20"/></p> <p> UDF: <input type="number" name="udfupdate" value="<?php echo $udfupdate; ?>" size="1" maxlength="4"/></p> <p> UDF2: <input type="number" name="udf2update" value="<?php echo $udf2update; ?>" size="1" maxlength="4"/></p> <p> UDF3: <input type="number" name="udf3update" value="<?php echo $udf3update; ?> " size="1" maxlength="4"/></p> <p> id: <input type="number" name="id" value="<?php echo $id; ?> " size="1" maxlength="4"/></p> <p><input type="submit" name="search" value="SEARCH"/></p> <p><input type="submit" name="update" value="UPDATE"/></p> <?php //update ext if ($_POST['search']) { $ext_formupdate = $_POST['ext']; $extract = mysql_query ("SELECT * FROM cy_equ WHERE ext='$ext_formupdate'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $equupdate = $row['equ']; $extupdate = $row['ext']; $udfupdate = $row['udf']; $udf2update = $row['udf2']; $udf3update = $row['udf3']; } if ($_POST['update']) { $sql = "UPDATE 'cy_equ' SET 'equ' = $_POST[equupdate], 'ext' = $_POST[extupdate], 'udf' = $_POST[udfupdate], 'udf2' = $_POST[udfupdate2], 'udf3' = $_POST[udfupdate3] 'id' = $_POST[id] WHERE id ='$_POST[id]'"; mysql_query($sql) or die(mysql_error()); } } ?>
  12. Hi all, First of all, I am a complete novice, but I’m trying my best. I have a data base with 6 fields, id, equ, ext, udf, udf2, udf3. I have created a web site that does various things like swap values, create new values, delete and search values. I'm struggling with searching for a particular value then editing fields and updating it. I hope that makes sense? Below is my code, I hope you can help. Jamie <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <?php //connect to database require("inc/conf.php"); if ($_POST['submit']) //run ext query { $ext_form = $_POST['ext']; $extract = mysql_query ("SELECT * FROM cy_equ WHERE ext='$ext_form'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $equ = $row['equ']; $ext = $row['ext']; $udf = $row['udf']; $udf2 = $row['udf2']; $udf3 = $row['udf3']; } } ?> <?php //swap ext numbers require("conf.php"); if ($_POST['swap']) { $exta = $_POST['exta']; $extb = $_POST['extb']; $result = mysql_query("SELECT id FROM cy_equ WHERE ext='$exta'"); $row = mysql_fetch_assoc($result); $ida = $row['id']; $result = mysql_query("SELECT id FROM cy_equ WHERE ext='$extb'"); $row = mysql_fetch_assoc($result); $idb = $row['id']; $update = mysql_query("UPDATE cy_equ SET ext='$extb' WHERE id='$ida'"); $update = mysql_query("UPDATE cy_equ SET ext='$exta' WHERE id='$idb'"); } ?> <?php //delete ext $deleting=("DELETE FROM cy_equ WHERE ext='$_POST[extdelete]'"); if (!mysql_query($deleting)) { die('Error: ' . mysql_error()); } ?> <?php //create ext $insert="INSERT INTO cy_equ (equ, ext, udf, udf2, udf3) VALUES ('$_POST[equcreate]','$_POST[extcreate]','$_POST[udfcreate]','$_POST[udfcreate2]','$_POST[udfcreate3]')"; if (!mysql_query($insert)) { die('Error: ' . mysql_error()); } ?> <?php //update ext if ($_POST['search']) { $ext_formupdate = $_POST['ext']; $extract = mysql_query ("SELECT * FROM cy_equ WHERE ext='$ext_formupdate'"); $numrows = mysql_num_rows ($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $equupdate = $row['equ']; $extupdate = $row['ext']; $udfupdate = $row['udf']; $udf2update = $row['udf2']; $udf3update = $row['udf3']; } if ($_POST['update']) { $sql = "UPDATE 'cy_equ' SET 'equ' = $_POST[equupdate], 'ext' = $_POST[extupdate], 'udf' = $_POST[udfupdate], 'udf2' = $_POST[udfupdate2], 'udf3' = $_POST[udfupdate3] 'id' = $_POST[id] WHERE id ='$_POST[id]'"; mysql_query($sql) or die(mysql_error()); } } ?> <body> <div class="boxextqry"> <h3> Ext Query </h3> <form name="form1" method="post" action="../index1.php?page=tele"> <p> Input Ext: <input type="number" name="ext" size="1" maxlength="4"/></p><br> <p> EXT = <font color="red"><?php echo $ext; ?> </font> </p> <p> EQU = <font color="red"><?php echo $equ; ?> </font></p> <p> UDF = <font color="red"><?php echo $udf; ?> </font></p> <p> UDF2 = <font color="red"><?php echo $udf2; ?> </font></p> <p> UDF3 = <font color="red"><?php echo $udf3; ?> </font></p> <p><input type="submit" name="submit" value="GET DATA"/></p> </form> </div> <div class="boxextswap"> <h3> Ext Swap </h3> <form name="form2" method="post" action="../index1.php?page=tele"> <p> Ext-A: <input type="number" name="exta" size="1" maxlength="4"/></p> <p> Ext-B: <input type="number" name="extb" size="1" maxlength="4"/></p> <p><input type="submit" name="swap" value="SWAP"/></p> </form> </div> <div class="boxextdelete"> <h3> Ext Delete </h3> <form name="form3" method="post" action="../index1.php?page=tele"> <p> Ext: <input type="number" name="extdelete" size="1" maxlength="4"/></p> <p><input type="submit" name="delete" value="DELETE"/></p> </form> </div> <div class="boxextcreate"> <h3> Ext Create </h3> <form name="form4" method="post" action="../index1.php?page=tele"> <p> EQU: <input type="number" name="equcreate" size="8" maxlength="20"/></p> <p> EXT: <input type="number" name="extcreate" size="1" maxlength="4"/></p> <p> UDF: <input type="number" name="udfcreate" size="1" maxlength="4"/></p> <p> UDF2: <input type="number" name="udfcreate2" size="1" maxlength="4"/></p> <p> UDF3: <input type="number" name="udfcreate3" size="1" maxlength="4"/></p> <p><input type="submit" name="create" value="CREATE"/></p> </form> </div> <div class="boxextupdate"> <h3> Ext Update </h3> <form name="form5" method="post" action="../index1.php?page=tele"> <p> Input Ext: <input type="number" name="ext" size="1" maxlength="4"/></p><br> <p> Ext: <input type="number" name="extupdate" value="<?php echo $extupdate; ?>" size="1" maxlength="4"/></p> <p> EQU: <input type="number" name="equupdate" value="<?php echo $equupdate; ?>" size="8" maxlength="20"/></p> <p> UDF: <input type="number" name="udfupdate" value="<?php echo $udfupdate; ?>" size="1" maxlength="4"/></p> <p> UDF2: <input type="number" name="udf2update" value="<?php echo $udf2update; ?>" size="1" maxlength="4"/></p> <p> UDF3: <input type="number" name="udf3update" value="<?php echo $udf3update; ?> " size="1" maxlength="4"/></p> <p> id: <input type="number" name="id" value="<?php echo $id; ?> " size="1" maxlength="4"/></p> <p><input type="submit" name="search" value="SEARCH"/></p> <p><input type="submit" name="update" value="UPDATE"/></p> </form> </div> </body> </html> </body> </html>
×
×
  • 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.