-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
Can not pull information that I need from Mysql...
Muddy_Funster replied to Collegeboox's topic in PHP Coding Help
Right then, your problem with the result set is that the scrip is simply calling the same querie 10 times. because you didn't open the { for the second while() then it couldn't run the condition for that properly. If you had included that you would have got 10 coppies of a table listing every entry for that date. Kill the Javascript, if you don't know what it's doing, don't have it in your page. try something along the following lines : <form action="backpack.php" method="post"> <?php // rows to return // $limit=10; **not used any more // $idcount=10; **not used any more $date = date('Y-m-d'); // $count = 0; **not used any more //while ($limit>=$count) **not used any more // { **not used any more //open database $connect = mysql_connect("hostname","uname","pass") or die("Not connected"); mysql_select_db("db_name") or die("could not log in"); $query = "SELECT *,COUNT(name) FROM boox WHERE date='$date' ORDER BY date LIMIT 10"; // use the SQL to limit the 10 results // $idcount = $row['COUNT(name)']; **not used any more // $result = mysql_query($query); **not used any more while($row = mysql_fetch_array($result)) { echo "</br><table width='297' height='200' border='1' align='center' style='overflow:scroll'> <tr> <td width='152'>Book Title:</td> <td width='129'>$row[name]</td> </tr> <tr> <td>Author:</td> <td>$row[author]</td> </tr> <tr> <td>ISBN#</td> <td>$row[isbn]</td> </tr> <tr> <td>Date Posted:</td> <td>$row[date]</td> </tr> <tr> <td>Posted By:</td> <td><a href='backpack.php?usr=".$row[username]."</a></td> </tr> <tr> <td>School:</td> <td>$row[school]</td> </tr> </table></br>"; // $count = $count + 1; **not used any more // $idcount = idcount + 1; **not used any more } ?> </form> then stick the following line near the top of backpack.php $userName = $_GET['usr']; echo $userName; -
It sounds, from what you have described, that your table structure needs some serious review. The information shown would work with the use of a NATURAL JOIN accross the four tables. Using JOIN establishes a relationship between the tables used. The type of JOIN used dictates the type of relationship, NORMAL and INNER joins provide a 1:1 relationship, one matching record from table 2 will be matched against a single record from table 1. Read up on the use of JOINS, it's something that you will need to know if you are planning on doing anything even a little bit complicated with multiple table queries.
-
problem with your insert is that you are missing the cling bracket on your VALUES statement, for the "not redirecting" thing, you will need to increase your validation if() at the top of the page to check for the exact conditions that you want to redirect on.
-
Redirecting to a new page after mysql insert
Muddy_Funster replied to perky416's topic in PHP Coding Help
you don't need to run the header() at the very top of the page, just before any output is sent to the browser. What you need to do is split your form and your insert script over different pages, then you can run the script and then use the header at the end of it. -
mysql_query($query) or die ('Deletion of table '$temp' failed! -- '.mysql_error()); my bad again...should be mysql_query($query) or die ('Deletion of table '.$temp.' failed! -- '.mysql_error());
-
Can not pull information that I need from Mysql...
Muddy_Funster replied to Collegeboox's topic in PHP Coding Help
not sure what the issue actualy is... are you getting the same result 10 times, or the same 10 different results each time you run the query? is there a reason that you have the result set limited to 10 in the php code rather than the SQL? <td><a href='backpack.php' onclick='document['packback'].submit()'>$row[username]</a></td> what is packback in relation to? is there a reason you are using javascript? $idcount = idcount + 1; this line is broken, not that it matters as you assign the value to $idcount each time you run through the while loop anyway. -
LAMP/WAMP/WIMP it's all the same at this level. What's the full code from the deletetable.php file (including the <?php and ?> tags)?
-
forgot the ; on the echo line :/ stick that in and see how we got on, you might also want to turn error reporting on for development.
-
could you change your code in deletetable.php to this and let us know what comes back : $temp = $_POST['temp']; $query = "DROP TABLE ".$temp; echo $query mysql_query($query) or die ('Deletion of table '$temp' failed! -- '.mysql_error()); echo "<h1 style='color:green;'>Table $temp deleted</h1>";
-
SELECT table1.field1, table1.field2, table2.field1, table2.field2, table2.field5, table3.field1, table3.field2, table3.field3 FROM table1 INNER JOIN table2 ON (table1.joinField = table2.joinField), table1 INNER JOIN table3 ON (table1.joinField = table3.joinField) WHERE ...discision clause You can use as many INNER, LEFT and RIGHT joins that you want.
-
not much use with php arrays myself, but this looks suspect : $allEmails[] = $mail; // add this address I would expect it should look like : $allEmails[$idi] = $mail; // add this address or $allEmails[] => $mail; // add this address But you'll need to look into it some more, as I said, I'm not too hot on php arrays.
-
How to send search keyword to external url in PHP Form
Muddy_Funster replied to PSM's topic in PHP Coding Help
yeah, my bad, forgot to escape the quotes, change to this and it should work: echo '$_POST[\'keyword\'] Assigned Value = <table border="1"><tr><th> '.$_POST['keyword'].' </th></tr></table><br>'; -
How to send search keyword to external url in PHP Form
Muddy_Funster replied to PSM's topic in PHP Coding Help
right, so we can safely say that $keyword is not getting assigned properly. sitck this code in just before the form and let me know what you get back, click your submit button a couple of times as well to see what happens for each run through. echo '$keyword Assigned Value = <table border="1"><tr><th> '.$keyword.' </th></tr></table><br>'; echo '$_POST['keyword'] Assigned Value = <table border="1"><tr><th> '.$_POST['keyword'].' </th></tr></table><br>'; you will also need to change your action page to just default.aspx, so that you can see the results. -
Not sure what it is that you expect to happen here. Could you give a bit more information regarding the context of the queries that you are running, and a breakdown of the data fields in your table?
-
How to send search keyword to external url in PHP Form
Muddy_Funster replied to PSM's topic in PHP Coding Help
right, lets get this line sorted out first, <form method="post" id="searchform" action="http://www.domain.com/default.aspx?st=FT&ss=<?php echo 'keyword'; ?>" /> [code=php:0] what you want this to do is : [code=php:0] <form method="post" id="searchform" action="http://www.domain.com/default.aspx?st=FT&ss=<?php echo $keyword; ?>" > [code=php:0] I also took the / out of your closing > (form is not a self closing tag) let me know what you get with that -
What you're looking for uses JOINs to run a single query against multiple tables for a specific result set based on all tables being linked through one or more common fields and the combined result set matching the criteria. JOINs are one of the most common functions in SQL, and you really should research them in depth in order to get a good understanding of them. You really want to avoid nesting queries inside of loops, it's potential to cause serrious problems is quite high.
-
Using include () within the <head> tags
Muddy_Funster replied to MortimerJazz's topic in PHP Coding Help
can you post up the code from your pages(both the php query and an example of the resulting erronious html) and we can have a look see what the problem may be? -
could it be reaching a thread limit? or perhaps it's buffer isn't clearing down after each runthrough? Just some ideas.
-
You must declare session_start(); before you process any output to the browser. try removing it from whjere you have it and putting it at the top of the code inside it's own <?php ?> tags. Also, thyat's a rather epic echo statement, think about alternatives to that (like include) As for the <div> tags not closing, it's never happend to me before...
-
Using returned sql query values as variables
Muddy_Funster replied to wright67uk's topic in MySQL Help
while ($row = mysql_fetch_array( $result )) { $message .= $row['email'].";" ; } should fill all your mail addresses into a format that will send. -
then you don't have a field named ordered in your database
-
How to send search keyword to external url in PHP Form
Muddy_Funster replied to PSM's topic in PHP Coding Help
ok, 2 quick questions Where, other than the page that you have posted the code from, is 'keyword' assigned? is the page that you have posted the code from actualy default.aspx? -
Basicly you just want to merge what you have already got into a third page. Run your select against the database, including the newsid field, and then produce your form using variables populated for the select to fill in the "value=" section of your text inputs. Add a hidden field that you can stuff the newsid into and then have your action page run an UPDATE rather than an INSERT INTO and you should be good to go.
-
Could you post up your code for the full queries please?
-
How to send search keyword to external url in PHP Form
Muddy_Funster replied to PSM's topic in PHP Coding Help
Try using $_GET['keyword']