gw32
Members-
Posts
33 -
Joined
-
Last visited
-
Days Won
1
Everything posted by gw32
-
pass variables from PHP mysql form to PHP mysql select/ while On same page.
gw32 replied to gw32's topic in MySQL Help
ERROR "lock development host system" should read "local development host system". -
pass variables from PHP mysql form to PHP mysql select/ while On same page.
gw32 replied to gw32's topic in MySQL Help
I had someone from my web host send me an example of a php.ini file which he advised me where to locate it and it works. Thanks. I would like to use a lock development host system, but for the life of me I can't understand how to setup ECLIPSE or MySQL/Apache/PHP on OS X Yosemite. Either i am too dumb or the instructions are not meant for first timers. If you know of a web site that offers instructions for either of these for beginners, I'll be very grateful. I'm learning a lot from this forum, keep up the good work. Thanks -
pass variables from PHP mysql form to PHP mysql select/ while On same page.
gw32 replied to gw32's topic in MySQL Help
Thanks, I'll try all suggestions. My ISP says that E_ALL and display_errors are both ON. -
I can't seem to understand how to do this. Can someone help? I created a form to select members and hit submit. Then I wan to ON SAME PAGE display the selected members information. {CODE} //This works echo "Select Player - "; echo "<select name='players'>"; while ($row = $result->fetch_assoc()) { unset($playersid, $name); $playersid = $row['playersid']; $name = $row['name']; echo '<option value="'.$playersid.'">'.$playersid.' - '.$name.'</option>'; } echo "$playersid"; echo "</select>"; echo '<font color="White"><input type="submit" value="Submit">'; // End works // THIS IS WHERE I AM STUCK $name = $_POST['name']; $playersid = $_POST['playersid']; // VARIABLES NOT PASSED //THIS IS DISPLAYED echo '<h3 class="pos_right">Weekly Report for $name</h3>'; echo '<p class="pos_right"> <table border="1"> <thead> <tr> <td align="center" width="75">Week<br>Played</td> <td align="center" width="75">Did They <br>Attend</td> <td align="center" width="75">Points</td> <td align="center" width="75">Amount<br>Paid</td> <td align="center" width="75">High<br>Hand</td> <td align="center" width="50">Fifty<br>Fifty</td> <tr> </thead>'; // SELECT PLAYER INFO FROM DATABASE //NOT WORKING, HERE. WORKS WELL IN MYSQL SQL $query = mysqli_query($conn,"SELECT b.week, a.attend, a.points, a.payout, a.hh, a.ff FROM data a, dates b, players c WHERE a.playersid = c.playersid AND a.dateid = b.dateid AND a.playersid = 12"); $res = mysqli_query( $conn, $query ) or exit( mysqli_error($conn) ); // NOTHING DISPLAYED while($row = mysqli_fetch_array($query)) { echo "<tr> <td>" . $row['week'] . "</td> <td>" . $row['attend'] . "</td> <td>" . $row['points'] . "</td> <td>$" . $row['payout'] . "</td> <td>$" . $row['hh'] . "</td> <td>$" . $row['ff'] . "</td> </tr>"; } echo "</table>"; {END CODE} This is the last script I need help with, all other 5 scripts wor well. Thanks for your help.
-
All set, please mark as answered. Thanks
-
Great advice and nice and soft slap on the hands. Eclipse will not run on my mac, something about JVD versions, did what it said to do and still no run. Will try Netbeans. As far as spaghetti code, I just sat down last week to try to develop a web site from my spreadsheets. My spreadsheets have all the right formulas and put things where they belong. Will let you know how things progress. Thanks for your help.
-
scrapped that whole script. went to this one. <?PHP include "config.php"; //THIS SECTION WORKS $sqld = "INSERT data2 (attend, payout, total)\n" . " SELECT sumofattend,\n" . " sumofpayout,\n" . " (sumofpayout - sumofattend) AS net_total\n" . " FROM (Select (SUM(attend) * 20) AS sumofattend,\n" . " SUM(payout) AS sumofpayout\n" . " FROM data\n" . " GROUP BY playersid) AS u"; $res11 = mysqli_query( $conn, $sqld ) or exit( mysqli_error($conn) ); $sqle = "INSERT data3 (t7, att)\n" . " SELECT sum(points > 0) as t7, sum(attend) as att\n" . " FROM data\n" . " GROUP BY playersid"; $res12 = mysqli_query( $conn, $sqle ) or exit( mysqli_error($conn) ); $sqlf = "INSERT data4 (pt7)\n" . " SELECT round(sum(t7 / att) * 100,0)\n" . " FROM data3\n" . " GROUP BY data3id"; $res13 = mysqli_query( $conn, $sqlf ) or exit( mysqli_error($conn) ); $sqlg = "INSERT data1 (`tpts`, `name`, `winning`, `high`, `fty`, `total`, `weeks`, `t7`, `pt7`, `wl`) \n" . " SELECT sum( a.points ), b.name, sum( a.payout ), sum( a.hh ), sum( a.ff ), sum( a.payout + a.hh + a.ff ), sum( a.attend ), d.t7, ab.pt7, c.total \n" . " FROM data a, players b, data2 c, data3 d, data4 ab \n" . " WHERE a.playersid = b.playersid and a.playersid = c.data2id and a.playersid = d.data3id and a.playersid = ab.data4id \n" . " GROUP BY b.name"; $res11 = mysqli_query( $conn, $sqlg ) or exit( mysqli_error($conn) ); echo mysqli_error(); // END OF THIS SECTION WORKS2 //THIS SECTION DOES NOT WORK $query = "SELECT * FROM data1 order by tpts desc"; while($row = mysqli_fetch_array($query)) { echo "<tr> <td><font color='white'></td> <td><font color='white'>.$row['tpts'].</td> <td><font color='white'>.$row['name'].</td> <td><font color='white'>.$row['winning'].</td> <td><font color='white'>.$row['high'].</td> <td><font color='white'>.$row['fty'].</td> <td><font color='white'>.$row['total'].</td> <td><font color='white'>.$row['weeks']?></td> <td><font color='white'>.$row['t7'].</td> <td><font color='white'>.$row['pt7'].</td> <td><font color='white'>.$row['wl'].</td> </tr>"; } ?> Same problem no screen output.
-
Thanks, I'll try to fix what you have indicated.
-
Oh Great GURU's of the PHP Relm, please help! I have this script and when I run it I get a blank screen. Every thing looks correct don't know what's wrong. SCRIPT: <?php include "config.php"; echo '<html>'; echo '<head> <style> p.pos_right { position: relative; left: 250px; top: 100px; } h3.pos_right { position: relative; left: 450px; top: 100px; } </style> </head>'; echo '<body>'; echo '<h3 class="pos_right">Weekly Report for <script type="text/javascript"> var d=new Date(); var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday", "Saturday"); var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); document.write(weekday[d.getDay()] + " "); document.write(monthname[d.getMonth()] + " "); document.write(d.getDate() + ", "); document.write(d.getFullYear()); </script></h3>'; $result = mysqli_query("SELECT * FROM data1 order by tpts desc"); echo '<p class="pos_right"> <table border="1"> <thead> <tr> <td align="center" width="50">Rank</td> <td align="center" width="50">Total<br>Pts</td> <td align="center" width="100">Name</td> <td align="center" width="75">Winnings</td> <td align="center" width="75">High<br>Hand</td> <td align="center" width="75">50-50</td> <td align="center" width="75">Total</td> <td align="center" width="50">Wks<br>Plyd</td> <td align="center" width="50">In Top<br>7</td> <td align="center" width="75">% in Top 7</td> <td align="center" width="75">Won /<br>Loss</td> <tr> </thead>'; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" .['tpts']. "</td>"; echo "<td>" .['name']. "</td>"; echo "<td>" "$" .['winning']. "</td>"; echo "<td>" "$" .['high']. "</td>"; echo "<td>" "$" .['fty']. "</td>"; echo "<td>" "$" .['total']. "</td>"; echo "<td>" .['weeks']. "</td>"; echo "<td>" .['t7']. "</td>"; echo "<td>" .['pt7']."%" "</td>"; echo "<td>" "$" .['wl']. "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($conn); echo '</body>'; echo '</html>'; ?>
-
I have the following script which works well as it is, but I need to add a column that ranks each player and that column is missing from the output. Script: if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // Truncate command $truncate = mysql_query("TRUNCATE TABLE $table"); if (!$truncate) { die("Query 1 to show fields from table failed"); } $sql = mysql_query("INSERT INTO $table(`Entry`, `Name`, `Points`, `Winnings`, `HH`, `Fty`, `Attend`) SELECT a.playersid as Entry, b.name as Name, sum(a.points) as Points, sum(a.payout) as Winnings, sum(a.high_hand) as HH, sum(a.fifty_fifty) as Fty, sum(attend) as Attend FROM data a, players b where a.playersid = b.playersid group by Entry"); if (!$sql) { die("Query 2 to show fields from table failed"); } // sending query $result = mysql_query("SELECT Name, Points, Winnings, HH, Fty, Attend FROM $table order by Points desc"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<h3>This Weeks Report: {$table}</h3>"; echo "<table border='1'><tr>"; echo "<tr><th>Rank</th><th>Name</th><th>Points</th><th>Winnings</th><th>High Hand</th><th>Fifty Fifty</th><th>Wks Pld</th></tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> I'm lost and the info I get from searching is confusing. Hope someone can help. Thanks
-
Found error about $sta. Thanks guys.
-
That worked. Now do I have this $sta=$row['status']; in the correct position? Thanks again
-
Syntax error found: unexpected T_ELSEIF on line 23 <?php require("config.php"); $result = mysql_query("SELECT name, mics, status, date_format(eventStart, '%M %e %Y') as start, date_format(eventFinish, '%M %e %Y') as end FROM events where status='S' or status='A' order BY eventStart"); $sta=$row['status']; { echo "<table rules='rows'> <tr> <th width='50'><font color='yellow' size='1'>MICS</th> <th width='200'><font color='yellow' size='1'>Charity</th> <th width='125'><font color='yellow' size='1'>Start Date</th> <th width='125'><font color='yellow' size='1'>End Date</th> </tr>"; while ($row = mysql_fetch_array($result)) { if ($sta == "A"); { echo "<tr>"; echo "<td><font color='red' size='1'>" . $row['mics'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['name'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['start'] . "</td>"; echo "<td><font color='red' size='1'>" . $row['end'] . "</td>"; echo "</tr>"; } elseif ($sta == "S"); { echo "<tr>"; echo "<td><font color='#ffffff' size='1'>" . $row['mics'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['name'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['start'] . "</td>"; echo "<td><font color='#ffffff' size='1'>" . $row['end'] . "</td>"; echo "</tr>"; } } echo "</table>"; } mysql_close($dbh); ?> [code] I don't see it. Thanks
-
This is probably easy but I can't get it. I have code like this: if ($sta == "A") { echo "<P><font size='+2' color='yellow'>Approved Charities</font></P>"; } elseif ($sta == "C") { echo "<P><font size='+2' color='yellow'>Contacted Charities</font></P>"; } elseif ($sta == "D") { echo "<P><font size='+2' color='yellow'>Declined Charities</font></P>"; } elseif ($sta == "S") { echo "<P><font size='+2' color='yellow'>Submitted Charities</font></P>"; } elseif ($sta == "CB") { echo "<P><font size='+2' color='yellow'>Call Back Charities</font></P>"; } elseif ($sta == "AP") { echo "<P><font size='+2' color='yellow'>Appointments with Charities</font></P>"; } elseif ($sta == "") { echo "<P><font size='+2' color='yellow'>All Charities</font></P>"; } Now I want to display only the rows that do not contain (A, C, D, S, CB, AP). Any help would be appreciated. Thanks
-
OK, the complete code for what I am trying to do. 1) select directory and image name. 2) preview that image 3) select and preview new image 4) upload new image with old image name. (This part is necessary, as I do not want to edit multiple XML files generated for a Carousel flash app) Complete code: Common stuff <?php ?> <html> <head> <style> body { background-color:#000000; color:#E27907; font-family:Verdana,Arial; font-size:10pt; letter-spacing:2; } .thumbNormal { border:4px solid #000000; } .thumbSelected { border:4px solid #ff0000; } .prevImage { border: 8px solid #ccc; width: 200px; height: 100px; } </style> <script language=javascript> var lastID = 0; function SelectImg(id) { if (lastID > 0) { document.getElementById(lastID).className = "thumbNormal"; } document.getElementById(id).className = "thumbSelected"; document.getElementById(0).src = document.getElementById(id).src; lastID = id; } function LoadTrigger() { SelectImg(1); } window.onload = LoadTrigger; </script> </head> Selecting Current Image <body> <table border=0 width="1000"> <tr> <td valign='top' width='45%' height="200">Select Directory and Image Name<p> <?php include("dd.php"); ?> <td valign='top' width='5%' height="200"> </td> <td valign='top' width='55%' height="200">Current Image to Replace.<p> <?php $id=$_POST['cat']; $name=$_POST['subcat']; $sql = "SELECT directory FROM directory WHERE DID = '$id'"; $result = mysql_query($sql) or die('A error occured: ' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $path = $row['directory']; print "<img class='thumbNormal' src='http://mysite.com/images/$path/$name' width=200 onclick='SelectImg($id)'>"; print "<br>"; print $path."/".$name; } ?> <td width=15> </td> <td valign=top> </td> </tr> <tr> <td valign=top></td> </tr> Select and Preview New Image <td valign='top' width='45%' height="200">Preview New Image.<p> <script type="text/javascript"> function setImage(file) { if(document.all) document.getElementById('prevImage').src = file.value; else document.getElementById('prevImage').src = file.files.item(0).getAsDataURL(); if(document.getElementById('prevImage').src.length > 0) document.getElementById('prevImage').style.display = 'block'; } </script> <form> <input type="file" name="myImage" onchange="setImage(this);" /><p> </form> <img id="prevImage" style="display:none;" /> </td> Upload New Image and Rename to Old Image Name <td valign='top' width='5%' height="200"> </td> <td valign='top' width='45%' height="200">Upload New Image.<p> <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $upload="http://mysite.com/images/" . $path; echo $upload; //we will give an unique name, for example the time in unix time format $image_name=$name; //the new name will be containing the full path where will be stored (images folder) $newname=$upload . "/" . $image_name; echo "<br>"; echo $newname; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; echo $copied; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; } ?> <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> End Code </table> </body> </html> Now if you follow it through as 1 single file, What am I doing wrong to pass the $path and $name to the bottom section of the file? Thanks
-
I thought that is what the manual said to do. First use $_POST to retrieve variables from url and then use $_GET to process them to the rest of the application. So which is correct and how do I pass the variables to the rest of the page?
-
This is probably a very easy question for experts like you guys, but it's driving me crazy. I have a URL passed variable that is used in the first section of my code. I use that to generate a second variable. The first variable gets the name of a file from a MySQL table. It also gets a directory from the table. Here is my dilemma, I need to pass the $name and $path to separate sections on the same page. For some reason I can't seem to get them down that far. Here is what I have for the first section of code. <?php $id=$_POST['cat']; //Passed from URL directory ID from table $name=$_POST['subcat']; //Passed from URL image name from table // Select Directory name to be used for $path $sql = "SELECT directory FROM directory WHERE DID = '$id'"; $result = mysql_query($sql) or die('A error occured: ' . mysql_error()); while ($row = mysql_fetch_assoc($result)) { $path = $row['directory']; // Preview image just selected print "<img class='thumbNormal' src='http://mysite.com/images/$path/$name' width=200 onclick='SelectImg($id)'>"; // Verify that the path select is correct print "<br>"; print $path."/".$name; } // Attempt to pass these variables to rest of page $path = $_GET['directory']; $name=$_GET['subcat']; ?> By the way I have different groups of things to do seperated by <tr>'s and <td>'s in the group that I need these variable passed to I have this. $upload="http://mysite.com/images/$path"; echo $upload; //we will give an unique name, for example the time in unix time format $image_name=$name; //the new name will be containing the full path where will be stored (images folder) $newname=$upload . "/" . $image_name; echo "<br>"; echo $newname; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; echo $copied; $errors=1; }}}} in my echo $upload I get "http://mysite.com/images/" - no path in my echo $newname I get "http://mysite.com/images//" - no image name What am I doing incorrectly? Thanks in advance
-
How do I get mySql data variables into this XML file? I've tried but get failure after failure. <?xml version="1.0" encoding="UTF-8"?> <Carousel> <photo image="images/main/bridal.jpg" url="http://tegodev.tegojewelers.com/Bridal/index.php" target="_self"><![CDATA[bridal]]></photo> </Carousel> I need to have this: main = $directory; bridal.jpg = $name; Bridal = $path; I can get all of the variables from the DB table no problem, but don't know enough about XML to put in variables. Thanks
-
Yes Sir.
-
Sir; My code is this: ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT directory, DID FROM directory order by directory"); ////////// Starting of first drop down list ///////// echo "<select name='id' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($var2 = mysql_fetch_array($quer2)) { if($var2['DID']==@$id){echo "<option selected value='$var2[DID]'>$var2[directory]</option>"."<BR>";} else{echo "<option value='$var2[DID]'>$var2[directory]</option>";} } echo "</select>"; [/color] I have this as a passed variable "select name='id'" and also this "$var2['DID']==@$id". Now what I need to pass is this "$var2[directory]". So how do I do it in it's present context. The complete code is listed earlier. Thanks
-
nope didn't work, I'll try a different method. Thanks
-
Because his solution, although is perfect for another program I am working on, would give me "firstfile.php?id=1_bridal" When the second sql statement reads $id it is looking for a number (1) the above is not in the table. the field in the table is DID (int, length 3).
-
That was my original question, how do I pass the variable '$var2[directory]' from the first drop down list select statement? Sorry I made it look and sound more difficult than it was supposed to be.
-
echo "<option value='$var2[DID]_$var2[directory]'>$var2[directory]</option>"; This would be fine, except that the $var2[directory] breaks the link to the next table lookup. I need it to look like this "firstfile.php?id=1" With your method it appears as "firstfile.php?id=1_pathname" and I get a data error. Here is the complete code for what I am trying to do. ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT directory, DID FROM directory order by directory"); /////// for second drop down list we will check if directory is selected else we will display all the names///// if(isset($id) and strlen($id) > 0){ $quer=mysql_query("SELECT DISTINCT name FROM images where DID=$id order by name"); }else{$quer=mysql_query("SELECT DISTINCT name FROM images order by name"); } echo "<form method=post name=f1 action='somefile.php'>"; ////////// Starting of first drop down list ///////// echo "<select name='id' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($var2 = mysql_fetch_array($quer2)) { if($var2['DID']==@$id){echo "<option selected value='$var2[DID]'>$var2[directory]</option>"."<BR>";} else{echo "<option value='$var2[DID]'>$var2[directory]</option>";} } echo "</select>"; ////////// Starting of second drop down list ///////// echo "<select name='name'><option value=''>Select one</option>"; while($var1 = mysql_fetch_array($quer)) { echo "<option value='$var1[name]'>$var1[name]</option>"; } echo "</select>"; echo "<input type=submit value=Submit>"; echo "</form>"; in somefile.php I have this: <body> <? $id=$_POST['id']; $image=$_POST['name']; $path=$_POST['path']; echo "Value of \$id = $id <br>Value of \$path = $path <br>Value of \$image = $image"; ?> As you can the path variable does not show up. I could possibly strip the path name from the second table lookup prior to doing the query. Thanks again.
-
I need to pass the variable "directory" along with $id. But the more I try the more errors I get, can some one please point me in the correct direction? echo "<form method=post name=f1 action='somefile.php'>"; echo "<select name='first' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; while($var2 = mysql_fetch_array($quer2)) { if($var2['DID']==@$id){echo "<option selected value='$var2[DID]'>$var2[directory]</option>"."<BR>";} else{echo "<option value='$var2[DID]'>$var2[directory]</option>";} } echo "</select>"; This is my first attempt with multiple MySQL/PHP forms. This selects the "id" from the first table and submits it to a new drop down list using a second table. The $id passes fine but I also need the variable 'directory' as $path. Thanks