
tjverge
Members-
Posts
118 -
Joined
-
Last visited
Everything posted by tjverge
-
I found the problem and found out something new $_POST and $_Post are not the same thing!
-
$stype does not have a value, it's empty when in this case it should be Test Ship 1
-
did not work, here is the output Array ( [ship] => Test Ship 1 [submit] => Join )
-
my html output, code still doesn't work <form action=main.php?id=joinop.php&opid=1 method=post> Ship Type: <select name = ship><option Value=Test%20Ship%201>Test Ship 1</option><option Value=Test%20Ship%202>Test Ship 2</option></select> <input name=submit type=submit value=Join> </form>
-
<form action="main.php?id=joinop.php&opid=1" method="post"> Ship Type: <select name ="ship">Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%201>Test Ship 1</option>Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%202>Test Ship 2</option></select> <input name=submit type=submit value=Join> </form>
-
I know the sql query is good because the drop down has the right items in it
-
the quotes didn't work, I tired echo $result; but it didn't show anything
-
<?php $opid = $_GET['opid']; $sql="Select * from `ships` WHERE `enabled` = 'Yes'"; $result = mysql_query($sql) or die (mysql_error()); echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> Ship Type: <select name = ship>"; while ($row = mysql_fetch_array($result)) { echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>"; } echo "</select> <input name=submit type=submit value=Join> </form>"; if (isset($_POST['submit'])) { $stype = rawurldecode($_Post['ship']); $stime = date("G:i:s",time()); $sql="Select * from `ships` WHERE `shiptype` = '$stype'"; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $weight = $row['weight']; } echo $stype; mysql_query ("INSERT INTO `ccccomma_eve`.`userops` (`id` ,`starttime` ,`endtime` ,`shiptype` ,`weight` ,`payout` ,`active`) VALUES ('$opid', '$stime', '', '$stype', '$weight', '', 'Yes')") or die (mysql_error()); Echo "Op Joined"; } ?> The variable is empty when I echo it out, any ideas on how to make to stick? Here is just the form that is giving me trouble echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> Ship Type: <select name = ship>"; while ($row = mysql_fetch_array($result)) { echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>"; } echo "</select> <input name=submit type=submit value=Join> </form>";
-
I found this function and take no credit for it, I'm trying to get it to show HH:MM:SS when I have the total number of seconds, but nothing is showing on the screen function sec2hms ($sec, $padHours = false) { // start with a blank string $hms = ""; // do the hours first: there are 3600 seconds in an hour, so if we divide // the total number of seconds by 3600 and throw away the remainder, we're // left with the number of hours in those seconds $hours = intval(intval($sec) / 3600); // add hours to $hms (with a leading 0 if asked for) $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ":" : $hours. ":"; // dividing the total seconds by 60 will give us the number of minutes // in total, but we're interested in *minutes past the hour* and to get // this, we have to divide by 60 again and then use the remainder $minutes = intval(($sec / 60) % 60); // add minutes to $hms (with a leading 0 if needed) $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ":"; // seconds past the minute are found by dividing the total number of seconds // by 60 and using the remainder $seconds = intval($sec % 60); // add seconds to $hms (with a leading 0 if needed) $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); // done! return $hms; } The part of the code to show the data is below: while ($row = mysql_fetch_array($result)) { $sec = time() - strtotime($row['starttime']); echo $sec; // print to screen to make sure $sec had a value sec2hms($sec); } Any guidance on where I went wrong?
-
the @ suppresses error messages for that line
-
Array ( [pi] => 2011-2-8 [pilotname] => TX [name] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 ) [submit] => Add )
-
I have a code that will enter the information into a database but as follows: A B C D E 1 2 3 4 5 I am looking for it all to be on the same row like: A B C D E 1 2 3 4 5 Here is my code: <?php if($_SESSION['admin'] !='Yes') { Echo "You are not approved to view this page!"; } Else { echo "<form action=main.php?id=test1.php method=post>"; echo "<table border=0>"; $sql = "select * from `pipilots` WHERE `enabled` = 'Yes' ORDER BY `pilot name` ASC"; $result = mysql_query($sql) or die (mysql_error()); ?> <td>Date</td> <td><input name="pi" id="pi" type="hidden" size="10"> <a href="javascript:NewCal('pi','YYYYMMDD')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td> <?php echo "<tr><td>Pilot Name: </td><td><select name = pilotname>"; while ($row = mysql_fetch_array($result)) { echo "<option Value=".rawurlencode($row['pilot name']).">".$row['pilot name']."</option>"; } echo "</select></td></tr>"; $sql = "select * from `piprice` WHERE `enabled` = 'Yes' ORDER BY `product name` ASC"; $result = mysql_query($sql) or die (mysql_error()); $count = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $pname[] = $row['product name']; echo "<tr><td>".$row['product name'].":</td><td> <input name=name[] type=text></td></tr>"; } echo"</table> <input name=submit type=submit Value=Add> </form>"; if(isset($_POST['submit'])) { $name = $_POST['name']; $date = $_POST['pi']; $pilotname = $_POST['pilotname']; echo rawurldecode($pilotname)."<br>"; echo $date."<br>"; for($i=0;$i<$count;$i++){ echo $pname[$i]." = ".$name[$i]."<br>"; $sql1="INSERT INTO `pi` (`pilot name`, `$pname[$i]`, `date`) VALUES ('$pilotname', '$name[$i]', '$date' )"; $result1=mysql_query($sql1) or die (mysql_error()); } }} ?> And this is the part that I think I need help with: if(isset($_POST['submit'])) { $name = $_POST['name']; $date = $_POST['pi']; $pilotname = $_POST['pilotname']; echo rawurldecode($pilotname)."<br>"; echo $date."<br>"; for($i=0;$i<$count;$i++){ echo $pname[$i]." = ".$name[$i]."<br>"; $sql1="INSERT INTO `pi` (`pilot name`, `$pname[$i]`, `date`) VALUES ('$pilotname', '$name[$i]', '$date' )"; $result1=mysql_query($sql1) or die (mysql_error()); } Any help would be great.
-
Problem solved, code posted below for anyone else who is having this kind of problem. <?php $sql ="select * from `piprice`"; $result = mysql_query($sql); $count = mysql_num_rows($result); echo "<table border=1><tr><td>Product Name</td><td>Item ID</td><td>Price</td><td>Enabled</td>"; echo "<form action=main.php?id=test1.php method=post>"; while ($row = mysql_fetch_array($result)) { echo "<tr><td>".$row['product name']."</td>"; echo "<td>".$id[] = $row['item id'];$row['item id']."</td>"; echo "<td>".number_format($row['price'],2)."</td>"; echo"<td><select name = ename[]> <option Value=".$row['enabled'].">".$row['enabled']."</option> <option Value=Yes>Yes</option> <option Value=No>No</option> /select></td</tr>"; } echo "<input name=submit type=submit value=Update>"; echo "</form></table>"; if(isset($_POST['submit'])) { $ename = $_POST['ename']; for($i=0;$i<$count;$i++){ echo $name; $sql1="UPDATE `piprice` SET `enabled` = '$ename[$i]' WHERE `item id` ='$id[$i]'"; $result1=mysql_query($sql1) or die (mysql_error()); } } ?>
-
Ok I think the problem is here $enabled[] = $row['enabled']; echo"<td><select name=".$enabled.">< <option Value=".$row['enabled'].">".$row['enabled']."</option> <option Value=Yes>Yes</option> <option Value=No>No</option> /select> I need to give it a name so I can pull the post date, the only problem is I'm unsure how to do that where it in a loop
-
Try this <?php require_once('/home/ffsports/mysql/db-connect.php'); // connect to db $query = "DELETE FROM tmpsessionmodule; INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module1 FROM session WHERE ((Module1) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module2 FROM session WHERE ((Module2) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module3 FROM session WHERE ((Module3) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module4 FROM session WHERE ((Module4) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module5 FROM session WHERE ((Module5) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module6 FROM session WHERE ((Module6) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module7 FROM session WHERE ((Module7) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module8 FROM session WHERE ((Module8) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module9 FROM session WHERE ((Module9) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module10 FROM session WHERE ((Module10) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module11 FROM session WHERE ((Module11) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module12 FROM session WHERE ((Module12) <>"" )"; $result = @mysql_query($query); // run the query ?> you where missing a ; on your last insert into
-
it's the complete code for this page, it's run inside another page that connects to the DB
-
I'm back, I have a code that based on my understanding should work, but needless to say doesn't <?php $sql ="select * from `piprice`"; $result = mysql_query($sql); $count = mysql_num_rows($result); echo "<table border=1><tr><td>Product Name</td><td>Item ID</td><td>Price</td><td>Enabled</td>"; echo "<form action=main.php?id=test1.php method=post>"; while ($row = mysql_fetch_array($result)) { echo "<tr><td>".$row['product name']."</td>"; echo "<td>".$id[] = $row['item id'];$row['item id']."</td>"; echo "<td>".$row['price']."</td>"; $enabled[] = $row['enabled']; echo"<td><select name=".$enabled.">< <option Value=".$row['enabled'].">".$row['enabled']."</option> <option Value=Yes>Yes</option> <option Value=No>No</option> /select></td</tr>"; } echo "<input name=submit type=submit value=Update>"; echo "</form></table>"; if(isset($_POST['submit'])) { for($i=0;$i<$count;$i++){ $sql1="UPDATE `piprice` SET `enabled` = '$enabled[$i]' WHERE `item id` ='$id[$i]'"; $result1=mysql_query($sql1) or die (mysql_error()); } } ?> Basically I want to be able to pick yes/no and have it update in the database. One a side note is there a good site for me to learn php on (I just know the basics) besides asking 101 questions here
-
That looks like it will work thank you
-
Try replacing === with ==
-
I'm not sure if this can be done, but I would like to get the sum for each $.row[''] result ex: if $row['robotics'] had values of 100,150,300 I would like to be able to show a total of 550 <?php echo "<Table border=1>"; echo "<tr><td></td><td>Robotics</td><td>Chiral Stuctors</td><td>Enriched Uranium</td><td>Mechanical Parts</td><td>Coolant</td><td>Consumer Electronics</td><td>Precious Metals</td><td>Reactive Metals</td><td>Oxygen</td><td>Toxic Metals</td></tr>"; $result = mysql_query("select * from `pi`"); while ($row = mysql_fetch_array($result)) { echo "<tr><td>".$row['pilot']."</td>"; echo "<td>".$row['robotics']."</td>"; echo "<td>".$row['chiralstuctors']."</td>"; echo "<td>".$row['enricheduranium']."</td>"; echo "<td>".$row['mechanicalparts']."</td>"; echo "<td>".$row['collant']."</td>"; echo "<td>".$row['consumerelectronics']."</td>"; echo "<td>".$row['preciousmetals']."</td>"; echo "<td>".$row['reactivemetals']."</td>"; echo "<td>".$row['oxygen']."</td>"; echo "<td>".$row['toxicmetals']."</td></tr>"; } echo "</table>"; ?>
-
It's solved thanks for you help you had the right idea with changing pidate to use ` chiralstuctors needed them too, thank you again for working with me on this
-
I put together a php code for it and it finds 1 record that way. $sql = "SELECT sum('chiralstuctors') FROM `pi` WHERE `pilot` = 'Test' AND `pidate` BETWEEN '2011-2-1' AND '2011-2-7'"; $results= mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($results); Echo $numrows. "Records found"; Is that what you meant by finding the number of records returned?
-
data type is bigint, and no all I did was run the query in phpmyadmin, I'm just looking for a sum of all the numbers in that column.