Jump to content

rajchahal

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rajchahal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi thanks for your reply, I have tried something similiar see line 3 of previous code. The problem is that all of table a with it's associated rows in table b are printed. I want to print ONLY 'table a' rows, and then manipulate the accociated entry in table b. I don't think it's a sql query problem but the way in which I am looping and prinding the data from the two tables, At the moment I'm going through the full array, need to print the records where only entries exist in 'table a'
  2. Here is the code, a bit of a mash up as I decided to normailise the data, instead of one table I'm now using 2 tables. I need to display the word 'lapsed' if todays date is greater than all occurances (unpub) the code below is still based on the single table so obviously won't work. table 2 has the following fields: id (primary key), publish(date),unpublish(date), showtime(varchar),id_article (foreign key) $result = mysql_query("SELECT * FROM articles"); // the line below prints out all of table a (articles) and any joining occurances in table b (article_occur) //$result = mysql_query("SELECT * FROM articles LEFT JOIN article_occur ON article_occur.id_article=articles.id_article "); <table width="800" border="1"> <tr> <td bgcolor="#FFFFCC">Ref</td> <td bgcolor="#FFFFCC">Category</td> <td bgcolor="#FFFFCC">Title</td> <td bgcolor="#FFFFCC">Edit</td> <td bgcolor="#FFFFCC">Status</td> <td width="17%" bgcolor="#FFFFCC">Enable</td> <td width="13%" bgcolor="#FFFFCC">Delete</td> </tr> <? while($row = mysql_fetch_array($result)) { ?> <tr> <td width="4%"><?=$row['id_article'] ?></td> <td width="4%"><?=$row['category'] ?></td> <td width="24%"><?=$row['title'] ?></td> <td width="11%"><a href="update_article.php?id=<?=$row['id_article']?>">edit</a></td> <td width="13%"> <? $dateMake = mktime(0,0,0,date("m"),date("d"),date("y")); $dateVal = date("Y-m-d", $dateMake); if (($dateVal > $row['unpub1']) and ($dateVal > $row['unpub2']) and ($dateVal > $row['unpub3'])and ($dateVal > $row['unpub3']) ) echo '<font color = red>Lapsed </font>'; else echo 'Active'; ?> </td> <td> <?php if ($row['enable'] ==1) echo "yes"; else echo '<font color = red>no</font>'; ?> </td> <td><a href="delete_article.php?id=<?=$row['id_article']?>&category=all" target="_self">delete </a></td> </tr> <? } ?> </table>
  3. hi I have two tables (table a - which contains the master record and table b - which contains the publish dates) - table b contains a foreign key to table a. I would like to display all of the contents in table a (as a list) and on the same line I would need to know from table b if the publish date has expired. I've tried left join, this lists all of table a but in addition it also replicates data from table b. Could someone explain how this can be done, I don't think I need to join the table..I think I'm having problems displaying the data. Help kindly appreciated.
  4. hi Background I'm creating an admin control panel. I have a whats on section that stores multiple dates for events, table 1 holds event info, name, location etc The 2nd table holds occurances of events, these are date pairs, publish-date and unpublish-date. On the admin page I would need to to insert items into table 1 and items into table2, but with table 2 I may have more than one occurance (record) to add. As I could have 1 or more sets of dates an event occurs on. I need only ONE button that would update both tables. Also, to make this a bit user friendly, with table 2 I would like to have a + / - buttons So I can either add another date pair or remove a date pair. So I'm assuming I need to use javacript to do this. The idea is to read table 2, put these occurances in a javascript array which also populates the required textfields, add some sorto of mechanism that can delete the textfield and update the array without refresh of page, once the submitted javascript transferes variables back to php and table1 and 2 are updated. I was hoping someone can help me with this. Appreciated Thanks
  5. Thanks for your reply My tables are already related, table 2 uses a foreign key that matches table1. But this is not what I meant, I want to have a page with data from two taples displayed on it, then I can update the fields, finally I want to press a single button to update both tables. The added complication is that I would like to add more than 1 occurance to table2. See attached image pls [attachment deleted by admin]
  6. hi there I have a whats on section, table 1 holds event info, name, location etc The 2nd table holds occurances of events, these are date pairs, publish-date and unpublish-date. On the admin page I would need to to insert items into table 1 and items into table2, but with table 2 I may have more than one occurance (record) to add. As I could have 2 sets of dates an event occurs on. I need only ONE button that would update both tables. Also, to make this a bit user friendly, with table 2 I would like to have a + / - buttons So I can either add another date pair or remove a date pair. Could someone explain how i can do this.. Code would be great ! Thanks
  7. This is a two part question: I have one table (articles) that containes all article info and publish date / unpublish date pairs - there are 4 pairs of dates. I've written this application, but now I realise I need to add 2 more date pairs. Practically, is it worth normalising this table? I was told it would simplyfy my sql queries? This leads me on to my next question, If I was to normalise i then would need to create a viewable relationship in mysql. In access a plus sign would indicate relationships, which could be easliy opened and closed. I would like to be able to view articles table with a subsection displaying article_occurance. how can I achieve this? I'm using mysql administrator 1.2.12. and willing to try some other administrive program if this doesnt do the job. Thank you
  8. hi again I've got the urls to work - thanks so much I'm now looking at sending a 404 error if someone goes to www.mysite.com/nopage you gave me the code: if(file_exists("pages/".$page.".php")){ //the file is valid, include it }else{ //404 error, include your 404 script. } The page.php is in the root, so I removed from the path 'pages/' But I keep getting the 404 error Is it possible to check the existance of a dynamic page in this way? as only page.php actually exists? I'm echoing the $page variable and this gives me the correct page name.
  9. Hi I think it was working all along (most of it anyway)- The problem was that when I was trying it, I was being served a page without css and assumed it wasn't working at all. Whats seems to be happening is that when I add RewriteRule ^whatson/([^/\.]+)/?$ whats_on_listing.php?viewstate=$1&nextvariable=$2 [L] to the htaccess it also alters the root folder path. Rather than the root being www.mysite.com it changes it to www.mysite.com/whats_on_listing.php so the stylesheet and images cant be found. I added ../ infront of the css file and it seems to now work, though a bit tedious. Is there something i could add in htaccess to solve this?
  10. hi again - sorry to keep this thread going - I've tried swapping the two lines to the top but still it does't work. then I tried to alter RewriteRule ^/press/$ press.php [L] to RewriteRule ^press$ press.php [L] I've removed forward slashes and now mysite.com/press works. I've also added this: RewriteRule ^whatson$ whats_on_listing.php [L] but the whats_on_listing.php i'm passing variables to on some occations, these are : whats_on_listing.php?viewstate=today whats_on_listing.php?viewstate=week whats_on_listing.php?viewstate=soon I want to achieve whatson/today whatson/week whatson/soon Thanks
  11. thanks the last two commands don't work. my .htaccess is RewriteEngine on RewriteRule ^([^/\.]+)/?$ page.php?page=$1 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ page.php?page=$1&section=$2 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ page.php?page=$1&section=$2&subsection=$3 [L] RewriteRule /whatson/^([^/\.]+)/?$ whats_on_article.php?id=$1 [L] RewriteRule ^/press/$ press.php [L] so if I go to url www.mysite.co.uk/press or www.mysite.co.uk/whatson I'm actually getting the wrong page (page.php) I've also notices if I type in a page that does not exist i.e www.mysite.co.uk/doesnotexist I'm also being served up page.php rather than a page not found error.. Any clues pls
  12. hi ProjectFear This worked first time - spot-on. It works with all directories. I also have other pages in the whats on section current URL is: http://www.mysite.co.uk/whats_on_article.php?id=22 - any suggestions on this ? maybe 'whats_on_article/22 ? and http://www.mysite.co.uk/press.php - how can I remove .php? Thanks again
  13. hi Could someone help with friendly url's pls. I already have a index.php page in the root and also a dynamic page called page.php - This page pulls database pages i.e contacts, cinema and so on. (using php5). If it's any easier I can move pages into folders and re-name to index.php ? My current url is www.mysite.co.uk/page.php?page=cinema and would like (prefer) www.mysite.co.uk/cinema or www.mysite.co.uk/page/cinema Thanks
  14. hi I've now realised I need 2 extra pairs, When you say 'If you normalized your data' dou you mean I require another table for date pairs and link this table to the events table? I was originally going to do this, but wouldn't the query be more complex ? can you give an example ? Thanks
  15. thought you might ask me this-- I'm using a wizzard in dreamweaver that picks out the fields from the database in this order. Dreamweaver then creates a form in the same order as the filelds in the database, which is in the incorrect order. So I have to manually move things around. Just figured if I could change the order in mysql it would speed things up for me. Thanks
×
×
  • 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.