rilana Posted January 6, 2009 Author Share Posted January 6, 2009 Hi guyes I am almost done, but still debugging.... One more Problem is that when I enter a line break, it' shows it in the mysql database, but when I echo it the line breaks want show because in html only <br> show a line breaks... How can I work arround this so it will be easy to add entrys with line breaks without having to use html??? I echo it like this: echo $fetchid['firmenbeschrieb']; I would aprechiate any sugestions, thank you verry much, Rilana Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 6, 2009 Share Posted January 6, 2009 nl2br Quote Link to comment Share on other sites More sharing options...
rilana Posted January 6, 2009 Author Share Posted January 6, 2009 Wow thanks xtopolis that works realy good! I was allready thinking I have to install a wysing... but this works perfect! thank you so much! Quote Link to comment Share on other sites More sharing options...
rilana Posted January 6, 2009 Author Share Posted January 6, 2009 is there anyway to reload a page? I have a delete Button which deletes an entry, but then the entry is still listed evan do it realy doesnt exist no more, only after a refresh it shows that the entry has been deleted. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 6, 2009 Share Posted January 6, 2009 Yes. I don't know how your page works though. If you're using Ajax, use javascript to remove that element.. If you're using PHP.. delete it and do a header redirect to the same page. You need to provide more information... and perhaps a link to your page. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 6, 2009 Author Share Posted January 6, 2009 the code is all on the same page. this is the delete part. <? if ($_POST["$delete"]) { $id = $_POST["id"]; $sql = "DELETE FROM jobs WHERE id='$id'"; $result = mysql_query($sql); echo "<script language=javascript> function closeWindow() { window.open('','_self',''); window.close(); } closeWindow(); </script>"; } ?> It is in a new window because bevor this code ist this one: echo " <a href='edit.php?cmd=edit&id=$id' target='_blank'>Editieren</a>"; Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 6, 2009 Share Posted January 6, 2009 hmm googling, I found this: http://forums.devarticles.com/javascript-development-22/auto-refresh-parent-window-after-closing-popup-4864.html Using javascript to close the popup and refresh the parent window. Check it out and see if you can get it to do what you want. (I'm not much with javascript popup windows) Quote Link to comment Share on other sites More sharing options...
rilana Posted January 7, 2009 Author Share Posted January 7, 2009 thank you. I will have to looke into it more, at first try I didnt get it running. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 7, 2009 Author Share Posted January 7, 2009 I have one more question. In the output of the jobs I have a link that looks like this. echo " <a href='edit.php?cmd=edit&id=$id' target='_blank'>Editieren</a>"; and then I have the code that referes to the cmd=edit. it basicly just says to show a different part of the page with a form if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["id"]; $sql = "SELECT * FROM jobs WHERE id=$id"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); echo "$test"; ?> <form action="edit.php" method="post"> <input type=hidden name="id" value="<?php echo $myrow["id"] ?>"> <input type=hidden name="datum" value="<?php echo $myrow["datum"] ?>"> <table width="100%" border="0"> <tr> <td width="115" align="left" valign="top">Position</td> <td width="435" align="left" valign="top"><TEXTAREA NAME="position" ROWS=1 ><? echo $myrow["position"] ?></TEXTAREA></td> </tr> <tr> </tr> <tr> <input name="user" type="hidden" value="smartpersonal" /><input name="pass" type="hidden" value="jobs311" /> <td align="left" valign="top"> </td> <td align="left" valign="top"><input type="submit" name="submit" value="submit" /> <label> <input type="submit" name="delete" id="delete" value="delete"/> </label> </td> </tr> </table> <input type="hidden" name="cmd" value="edit"> </form> And then in the end some php to update <? if ($_POST["$submit"]) { $position = $_POST["position"]; $sql = "UPDATE jobs SET position='$position', datum='$datum', firmenbeschrieb='$firmenbeschrieb', stellenbeschrieb='$stellenbeschrieb', kandidatenprofil='$kandidatenprofil', angebot='$angebot', kontakt='$kontakt', datumsanzeige='$datumsanzeige', beruf='$beruf', region='$region', anstellung='$anstellung' WHERE id=$id"; $result = mysql_query($sql); echo "Danke"; echo "<script language=javascript> function closeWindow() { window.open('','_self',''); window.close(); } closeWindow(); </script>"; } } ?> Now, I do have a delete Button as you can see on the form part. this one works fine. With this code.. <? if ($_POST["$delete"]) { $id = $_POST["id"]; $sql = "DELETE FROM jobs WHERE id='$id'"; $result = mysql_query($sql); echo "<script language=javascript> function closeWindow() { window.open('','_self',''); window.close(); } closeWindow(); </script>"; } ?> But what I would like to do now is to put one more Link next to de edit Link which I posted first so I would be able to delete the entry right away, bevor even look at the edit part. I there a possibility to do that? How can I make a link that reffers to if ($_POST["$delete"])? Hopefully you understand what I mean. It would be cool if I could say something like echo " <a href='edit.php?submit=delete&id=$id' target='_blank'>Loeschen</a>"; But to bad, it does not work..... Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 7, 2009 Share Posted January 7, 2009 Firstly, you need to escape/verify your values so that you don't get injected!!! $id = intval($_GET["id"]); $position = mysql_real_escape_string($_POST["position"]);//assuming this is a string $id = intval($_POST["id"]); Also you are typing: $_POST["$submit"] $_POST["$delete"] for some reason... Don't use the dollar signs when referring to the variable names. Secondly, your url is not sending the variable as you expect: echo " <a href='edit.php?submit=delete&id=$id' target='_blank'>Loeschen</a>"; Sends the post vars: $_POST['submit'] and $_POST['id'] You look for if ($_POST["$delete"]) ^ this is also wrong as I don't see $delete being defined anywhere so you could change it to: if ($_POST['submit']=='delete') That should get you started, can't look at it more thoroughly as I'm off to work. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 7, 2009 Author Share Posted January 7, 2009 thank you I wish you a good day at work... I am going to sleep now.... Quote Link to comment Share on other sites More sharing options...
rilana Posted January 10, 2009 Author Share Posted January 10, 2009 Big Problem I dont know how to solve... Up to now the database part was all fine and I was more or less finetuning the rest. But now I have a prblem which I dont know how to solve. It's complicated but I am trying to explain this best ein can. Till now there was one entry in the database called beruf (means job) and every job entry had one word in beruf lets say tech, this meant that the joblisting was a technical job. In the frontend there are checkboxes which searched for the checked jobcategorie. Fontend: <input type="checkbox" name="beruf[]" value="kauf', 'tech', 'kader', 'bau', 'informatik', 'verkauf" />Alle Berufe<br /> <input type="checkbox" name="beruf[]" value="tech" />Technische Berufe<br /> <input type="checkbox" name="beruf[]" value="bau" />Bau<br /> <input type="checkbox" name="beruf[]" value="verkauf" />Verkauf<br /> <input type="checkbox" name="beruf[]" value="kauf" />Kaufmännische Berufe<br /> <input type="checkbox" name="beruf[]" value="kader" />Kader<br /> <input type="checkbox" name="beruf[]" value="informatik" />Informatik</td> Backend: $where = array(); $whereclause = ''; if (isset($_POST['beruf'])) { $berufe = join("', '", $_POST['beruf']); $where[] = "(beruf IN ('$berufe'))" ; } if (isset($_POST['anstellung'])) { $anstellungen = join("', '", $_POST['anstellung']); $where[] = "(anstellung IN ('$anstellungen'))" ; } if (count($where) > 0) $whereclause = ' WHERE ' . join (' AND ', $where); $sql = "SELECT * FROM jobs $whereclause order by datumsanzeige = 'fake' DESC, datum DESC"; But my client has a new wish. There are joblistings that have more then one jobcategorie for example a technical job can also be in the office... ore something like that. So basicaly he wants to be able to give a singel jobentry more then one catagorie. To solve this I was thinking to just make one more entry in the database called beruf2 (second jobcategory). But now I cant figure out how to work it on the frontend. I would have to say something like if beruf is checked, get all the checked values and make an array, then get then list all the mysql entrys that have the previous checked values in beruf and beruf2... I tryed this: if (isset($_POST['beruf'])) { $berufe = join("', '", $_POST['beruf']); $where[] = "(beruf IN ('$berufe'))" ; [color=red]$where[] = "(beruf2 IN ('$berufe2'))" ;[/color] } But that does not work at all. I hope somebody understand what I mean and can give me a help. I would realy aprechiated! Thank you so much, Rilana Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 10, 2009 Share Posted January 10, 2009 No; you should normalize your table. You currently have a column called beruf which stores a word representation of a category. That worked until now when your requirements changed. You should remove that column and create a 2 new tables: beruf_categories -------------------- -berufID -categoryID categories ------------ categoryID name You can change the names to be whatever you want. beruf_categories will hold one entry per category the job belongs to. So if the job belonged to the category "office" and "technical", the beruf_categories table would have two rows like this: beruf_categories ------------------ 1 - 1 1 - 2 and categories would have 2 or more entries categories ------------ 1 - office 2 - technical example: SELECT beruf.name FROM beruf b JOIN beruf_categories bc USING(b.berufID) WHERE bc.categoryID IN ('1','2') Not tested.. may be a little off So using the "one - to - many" relationship of job -> categories you can selected jobs that are IN() the categories checked. The checkboxes could return numerical values that relate to the categories available. You could even have it build the checkboxes by SELECT * FROM categories. Hopefully that makes sense, if not, let us know. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 10, 2009 Author Share Posted January 10, 2009 wow I was just reading your post like 10 times trying to understand, but I just dont get it... isn't there an easier way? I was thinking maby someting like saying the array beruf2 has the same input as beruf then go look in the database and list all the entrys that have any maches... Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 10, 2009 Share Posted January 10, 2009 example: CREATE TABLE `jobs` ( `jobID` int(11) NOT NULL auto_increment, `jobName` varchar(50) collate latin1_german2_ci NOT NULL, `jobDesc` varchar(500) collate latin1_german2_ci NOT NULL, PRIMARY KEY (`jobID`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `jobs` -- INSERT INTO `jobs` VALUES (1, 'Programmer', 'Program for our company in C++'); INSERT INTO `jobs` VALUES (2, 'Secretary', 'Take phone calls, notes, schedule appointments.'); CREATE TABLE `categories` ( `catID` int(11) NOT NULL auto_increment, `catName` varchar(50) collate latin1_german2_ci NOT NULL, PRIMARY KEY (`catID`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` VALUES (1, 'Office'); INSERT INTO `categories` VALUES (2, 'Technical'); CREATE TABLE `jobs_categories` ( `jobID` int(11) NOT NULL, `catID` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; -- -- Dumping data for table `jobs_categories` -- INSERT INTO `jobs_categories` VALUES (1, 1); INSERT INTO `jobs_categories` VALUES (1, 2); INSERT INTO `jobs_categories` VALUES (2, 1); SELECT j.jobID,j.jobName,j.jobDesc,c.catName FROM jobs j JOIN jobs_categories jc ON(j.jobID = jc.jobID) JOIN categories c ON(jc.catID = c.catID) WHERE j.jobID IN(1) If you change the IN clause to be 2, or 1,2 you will see the results. Selecting 1,2 would show jobs that are either in the Office category, or the Technical category. Play around with that, see if it makes any sense. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 11, 2009 Author Share Posted January 11, 2009 Thank you so much, but I am afraid that I am an idiot, I didnt evan get any output! <? $con = mysql_connect("localhost", "smartper_smart", "smart") or die(mysql_error()); mysql_select_db("smartper_jobs") or die(mysql_error()); mysql_query("SET NAMES 'UTF8'"); $sql = "SELECT j.jobID,j.jobName,j.jobDesc,c.catName FROM jobs2 j JOIN jobs_categories jc ON(j.jobID = jc.jobID) JOIN categories c ON(jc.catID = c.catID) WHERE j.jobID IN(1)"; $result = mysql_query($sql, $con) or trigger_error("SQL", E_USER_ERROR); while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td class='stellen'>"; echo $row['JobName']; echo "</td></tr><tr><td>"; echo substr($row['JobDesc'],0,100); echo "... "; echo "<a href=\"stellenDetail.php?id=$row[id]\">|weiter > </a>"; echo "</td></tr>"; echo "<tr><td>"; echo "</td></tr>"; echo "<tr><td colspan='2' class='line'><br></td><td></td></tr>"; } echo "<tr><td>"; ?> why are the j. in front for? j.jobID,j.jobName Sorry, I realy wished there would be an easier way. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 11, 2009 Author Share Posted January 11, 2009 I was reading up the whole day on join... I start to get the princip more, but still want come to an output. I also tryed to sructure my database new. Now I have a table jobs with all the single imput possibilitys, then a table region with region_id and region_name, a table job_region with job_id and region_id, a tabel profession with profession_id and profession_name and a table jobs_profession with job_id and profession_id..... I am wondering if this is evan gonna work..... I am still reading up and trying to figure it out more, but I would highly apreciate any help! Thank you so much, Rilana Quote Link to comment Share on other sites More sharing options...
rilana Posted January 11, 2009 Author Share Posted January 11, 2009 ok finaly I hade a little bit success, I wrote it like that $sql = "SELECT * FROM jobs2 JOIN jobs_categories ON jobs_categories.jobID=jobs2.jobID JOIN categories ON categories.catID=jobs_categories.catID WHERE jobs2.jobID IN(1)"; And this works now. But now I have to find out how to do this out of a form jeee.... I feel so smart and dumm at the same time! Quote Link to comment Share on other sites More sharing options...
rilana Posted January 11, 2009 Author Share Posted January 11, 2009 ok, I am getting closer... I did this: SELECT * FROM jobs2 JOIN jobs_categories ON jobs_categories.jobID=jobs2.jobID JOIN categories ON categories.catID=jobs_categories.catID WHERE categories.catName IN ('office','technical') This seemed to work. But then I tryed to make the WHERE dynamic.... Like this: if (isset($_POST['btnSubmit'])) { $where = array(); $whereclause = ''; if (isset($_POST['categories'])) { $categoriess = join("', '", $_POST['categories']); $where[] = "catName IN ('$categoriess')" ; } if (count($where) > 0) $whereclause = ' WHERE ' . join (' AND ', $where); $sql = "SELECT * FROM jobs2 JOIN jobs_categories ON jobs_categories.jobID=jobs2.jobID JOIN categories ON categories.catID=jobs_categories.catID WHERE categories.('$whereclause')"; echo $sql; $result = mysql_query($sql, $con) or trigger_error("SQL", E_USER_ERROR); } while($row = mysql_fetch_array( $result )) { //print table echo "<p>"; echo $row['jobID']; echo $row['jobName']; echo $row['jobDesc']; echo $row['catID']; echo $row['catName']; echo "</p>"; } ?> <form method="POST"> <h3>categories</h3> office <input type='checkbox' name='categories[]' value='office'><br /> technical <input type='checkbox' name='categories[]' value='technical'><br /> <input type='submit' name='btnSubmit' value='Submit'> </form> But this gives me an mysql output thats a bit off unstead of saying WHERE categories.catName IN ('office','technical') it says WHERE categories.(' WHERE catName IN ('office', 'technical')') Please help, what do I need to change so it will work??? I am wondering if I will be able to do this with more Wheres..... but I guess thats the next step.... thank you, Rilana Quote Link to comment Share on other sites More sharing options...
rilana Posted January 11, 2009 Author Share Posted January 11, 2009 Now my output is ' WHERE categories.catName IN ('office', 'technical')' so there are only '' to many to my soulution I beleve.... where do I take them away? if (isset($_POST['btnSubmit'])) { $where = array(); $whereclause = ''; if (isset($_POST['categories'])) { $categoriess = join("', '", $_POST['categories']); $where[] = "categories.catName IN ('$categoriess')" ; } if (count($where) > 0) $whereclause = ' WHERE ' . join (' AND ', $where); $sql = "SELECT * FROM jobs2 JOIN jobs_categories ON jobs_categories.jobID=jobs2.jobID JOIN categories ON categories.catID=jobs_categories.catID '$whereclause'"; Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 11, 2009 Share Posted January 11, 2009 Hey. First, here is a good article on database normalization http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html . You should check it out if you have not seen it. Secondly, I have created a small example that you can look at and examine. Play around with it and see how different check boxes show different things, then look at the source code to see how I did it. I do not recommend copying it as it is only an example. However feel free to take ideas from it and apply it to your own work. Things that could use improvement from mine are: verifying post values (converting them to numbers for sure, etc), a better way to handle my WHERE clause additions. Here is the source: TABLES CREATE TABLE `categories` ( `catID` int(11) NOT NULL auto_increment, `catName` varchar(50) collate latin1_german2_ci NOT NULL, PRIMARY KEY (`catID`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` VALUES (1, 'Office'); INSERT INTO `categories` VALUES (2, 'Technical'); CREATE TABLE `jobs` ( `jobID` int(11) NOT NULL auto_increment, `jobName` varchar(50) collate latin1_german2_ci NOT NULL, `jobDesc` varchar(500) collate latin1_german2_ci NOT NULL, PRIMARY KEY (`jobID`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `jobs` -- INSERT INTO `jobs` VALUES (1, 'Programmer', 'Program for our company in C++'); INSERT INTO `jobs` VALUES (2, 'Secretary', 'Take phone calls, notes, schedule appointments.'); CREATE TABLE `jobs_categories` ( `jobID` int(11) NOT NULL, `catID` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; -- -- Dumping data for table `jobs_categories` -- INSERT INTO `jobs_categories` VALUES (1, 1); INSERT INTO `jobs_categories` VALUES (1, 2); INSERT INTO `jobs_categories` VALUES (2, 1); CREATE TABLE `jobs_regions` ( `jobID` int(11) NOT NULL, `regionID` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; -- -- Dumping data for table `jobs_regions` -- INSERT INTO `jobs_regions` VALUES (1, 2); INSERT INTO `jobs_regions` VALUES (2, 1); CREATE TABLE `regions` ( `regionID` int(11) NOT NULL auto_increment, `regionName` varchar(75) collate latin1_german2_ci NOT NULL, PRIMARY KEY (`regionID`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `regions` -- INSERT INTO `regions` VALUES (1, 'Germany'); INSERT INTO `regions` VALUES (2, 'France'); Sample page: <?php $db = MYSQL::get(TEST_HOST,TEST_UN,TEST_PW,TEST_DB); // ^ PUT YOUR DATABASE STUFF HERE, CHANGE MY $db->query() to be like your mysql_query() methods ?> <html> <head> </head> <body> <?php if(!isset($_POST['submitSearch'])) { //get list of regions,job types $regionsSQL = "SELECT regionID,regionName FROM regions WHERE 1"; $categoriesSQL = "SELECT catID,catName FROM categories WHERE 1"; $regionsResult = $db->query($regionsSQL); $categoriesResult = $db->query($categoriesSQL); ?> <!-- form not set, show options --> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <div style="border: 1px solid black;float: left;text-align: right; padding: 5px;";> <?php while(list($rID,$rName) = mysql_fetch_array($regionsResult)){ echo "<label>$rName</label><input type='checkbox' name='region[]' value='$rID' /><br />"; } ?> </div> <!-- categories --> <div style="border: 1px solid black;float: left;text-align: right; padding: 5px;";> <?php while(list($cID,$cName) = mysql_fetch_array($categoriesResult)){ echo "<label>$cName</label><input type='checkbox' name='category[]' value='$cID' /><br />"; } ?> </div> <br style="clear: both;" /> <input type="submit" name="submitSearch" value="Search" /> </form> <!-- FORM WAS SUBMITTED : PROCESS IT --> <?php } else { if(!$_POST['region'] && !$_POST['category']){ die('You did not select a region or category.<p><a href="'.$_SERVER['PHP_SELF'].'">Back</a></p>'); } $addRegion = false; $addCategory = false; if($_POST['region']){ $regions = implode("','",$_POST['region']);// YOU SHOULD ESCAPE/CONVERT THESE VALUES $whereRegion = "r.regionID IN('".$regions."')"; $addRegion = true; } if($_POST['category']){ $categories = implode("','",$_POST['category']);// YOU SHOULD ESCAPE/CONVERT THESE VALUES $whereCategory = "c.catID IN('".$categories."')"; $addCategory = true; } $search = "SELECT DISTINCT j.jobID, j.jobName, GROUP_CONCAT(c.catName), r.regionName FROM jobs j JOIN jobs_categories jc ON(j.jobID = jc.jobID) JOIN categories c ON(jc.catID = c.catID) JOIN jobs_regions jr ON(j.jobID = jr.jobID) JOIN regions r ON(jr.regionID = r.regionID)"; $where = ' WHERE '; $group = ' GROUP BY j.jobID'; if($addRegion && $addCategory){ $search .= $where . $whereRegion . " AND " . $whereCategory . $group; }else if($addRegion && !$addCategory){ $search .= $where . $whereRegion . $group; }else{ $search .= $where . $whereCategory . $group; } $jobs = $db->query($search); if(mysql_num_rows($jobs) == 0){ die('No jobs matched your query.<p><a href="'.$_SERVER['PHP_SELF'].'">Back</a></p>'); } echo '<p><a href="'.$_SERVER['PHP_SELF'].'">Back</a></p>'; echo '<table>'; echo '<tr><td>Job ID</td><td>Job Name</td><td>Job Type</td><td>Region</td></tr>'; while(list($jID,$jName,$cName,$rName) = mysql_fetch_array($jobs)){ echo "<tr>"; echo "<td>$jID</td><td>$jName</td><td>$cName</td><td>$rName</td>"; echo "</tr>"; } echo '</table>'; } ?><!-- endif --> </body> </html> Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 11, 2009 Share Posted January 11, 2009 I forgot to mention: Using GROUP_CONCAT as I did in this example should also be reworked. Group concat has a 1024 character limit. You should not use it in the way I did, perhaps you could select only the IDs and later convert the IDs->Names Quote Link to comment Share on other sites More sharing options...
rilana Posted January 13, 2009 Author Share Posted January 13, 2009 Thank you verry much. I didn't have time to look into it yet, but I defenetly will play arround with it some more... I think I start getting it. I got one moe question that I am allready thinking of running into a problem. In the backend I will have one form, but since I spilt the data into different tables, I am wondering how my sql querrie would look, I mean is there a possibility to send more then one query with one form? Thank you verry much, Rilana Quote Link to comment Share on other sites More sharing options...
xtopolis Posted January 13, 2009 Share Posted January 13, 2009 You probably won't be letting users make their own categories on the fly.(meaning at the time they add a job). Regions won't change, you will make a predefined list and have them choose from it. There aren't that many types, and you can always add more if YOU feel you need them... but you shouldn't be letting users add them willy nilly.. and if you do, have it create it instantly(Ajax) and update the form so that it is now selectable. Quote Link to comment Share on other sites More sharing options...
rilana Posted January 13, 2009 Author Share Posted January 13, 2009 Now I just realized that my pagination script does not work. I think it's because of the sql query beeing lost when I reload the page. so when ever i klick on the link it looses the query and just gives me all the entrys of the database unstead. if (isset($_POST['btnSubmit'])) { $where = array(); $whereclause = ''; if (isset($_POST['region'])) { $regions = join("', '", $_POST['region']); $where[] = "(region IN ('$regions'))" ; } if (isset($_POST['beruf'])) { $berufe = join("', '", $_POST['beruf']); $where[] = "(beruf IN ('$berufe'))" ; } } $sql = "SELECT * FROM jobs $whereclause order by datumsanzeige = 'fake' DESC, datum DESC"; $result = mysql_query($sql,$con); $r = mysql_fetch_row($result); $numrows = $r[0]; $numrows = mysql_num_rows ($result); so this will be the query after I send a form ahead of this. Then when I klick on a link like this // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ it reloads the page and will empty the query. How can I make shoure the query is keept during the reloading? I tryed the following thing, but they didnt work: echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&whereclause=$whereclause'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&result=$result'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage®ion=$region'>></a> "; } // end if /****** end build pagination links ******/ How can I send the query so it want get loost when I go thrue pages? Please help. I would realy apreciate it. Thank you so much.... rilana Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.