Jump to content

chris9902

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

About chris9902

  • Birthday 06/17/1986

Profile Information

  • Gender
    Not Telling
  • Location
    UK

chris9902's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help. You pointed me in the right direction. I was looking for "mysql_num_rows" but couldn't remember how to count the rows (been a while since I've used PHP) I also needed IDs not classes (my mistake) so they have to be unique. Anyway here is my final code. works just as I wanted. $count = 1; $total = mysql_num_rows($result); while ($are=mysql_fetch_array($result)) { $name = $are['name']; $url = $are['url']; if ($count == 1) { print '<li><a href="'.$url.'" id="left">'.$name.'</a></li>'."\n"; } elseif ($count == $total) { print '<li><a href="'.$url.'" id="right">'.$name.'</a></li>'."\n"; } else { print '<li><a href="'.$url.'">'.$name.'</a></li>'."\n"; } $count++; } Thanks again for the quick reply. (why does this forums change the letter next to e on the keyboard to "are"?)
  2. probably very simple but I need to apply a class to the first and last records from a MySQL query. What I'm trying to do is pull the menus for my site but the first and last links need a class name for the design. I can't set them in the database because the order and items in the menu will change from time to time. so, here is how I pull my menu (cut down for this post). You can see it just grabs the name, url and makes a link. How would I apply a class to the first and last records? mysql_connect("localhost","root","password"); mysql_select_db("my_site"); $result = mysql_query("SELECT * FROM menu ORDER BY id"); while ($are=mysql_fetch_array($result)) { $name = $are['name']; $url = $are['url']; print '<a href="'.$url.'">'.$name.'</a>'."\n"; }
  3. the problem line is: "$taxonomyTerm = 2" you need a ";" after 2 so it should be "$taxonomyTerm = 2;"
  4. what he posted was shorthand for the IF ELSE statment. <?php ($var ? TRUE : FALSE); ?> what this is saying is what is $var TRUE or FALSE. if TRUE do the first thing else or do the second thing. so  <?php ($random_variable1 ? echo "checked" : ""); ?>    means, if $random_variable1 is TRUE echo "checked" else do nothing. or another way to think of it is how it looks. $random_variable1 ? so you're asking what is $random_variable1, TRUE or FALSE. if it's TRUE do the first thing or (or is represented with a [b]:[/b] ) do the other thing.
  5. thank for the reply. I had something like this already but as you say it's a bit nasty. I was hoping there was a way to just trim the Array down to 10 or something. I can't seem to find anything in the manual about it.
  6. Hi all. It's monday and my brain no wants to work good! Making a very basic RSS reader and I want to limit the amount of data in an Array to say 10 stories. here is the code so far. [code]$xml[] = 'http://digg.com/rss/index.xml'; $xml[] = 'http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'; function get_RSS($url) { $RSS = simplexml_load_file($url); echo '<h1><a href="' . $RSS->channel->link . '">' . $RSS->channel->title . '</a></h1>'; foreach ($RSS->channel->item as $article) { echo '<ul>' . "\n"; echo '  <li class="title"><a href="' . $article->link . '">' . $article->title . '</a></li>' . "\n"; echo '  <li class="description">' . $article->description . '</li>' . "\n"; echo '  <li class="pubDate">' . $article->pubDate . '</li>' . "\n"; echo '</ul>' . "\n\n"; } } get_RSS($xml[0]); [/code] so right now it takes digg's feed and prints all the headlines but i want to limit it to 10. How can I do that? cheers :)
  7. I have a script and I need to check the input of a date to make sure it's valid. I need it to check if the date exists because it's for bookings and I don't want people trying to book on the 31st of Feb  ;) anyway. I found this funtion [url=http://uk.php.net/manual/en/function.mcal-date-valid.php]mcal_date_valid()[/url] and it looks like it does what I need it to do but when I try and call it I just "Fatal error: Call to undefined function". I'm running PHP 4.4.4 on my localhost that I set up about 20 minutes ago and I'm just wondering could it be I don't have the extension installed or is this funtion not valid anymore? also if anyone has a funtion to check a date please please post it  :) Thanks all.
  8. ;) told you it had been a long time. man I need some books.
  9. it's not the best way but this should work (i think) [code]<table>   <tr>     <td <?php if (date("D") == "Mon") echo('class="highlight"')?>>Monday</td>     <td <?php if (date("D") == "Tue") echo('class="highlight"')?>>Tuesday</td>     <td <?php if (date("D") == "Wed") echo('class="highlight"')?>>Wednesday</td>     <td <?php if (date("D") == "Thu") echo('class="highlight"')?>>Thursday</td>     <td <?php if (date("D") == "Fri") echo('class="highlight"')?>>Friday</td>     <td <?php if (date("D") == "Sat") echo('class="highlight"')?>>Saturday</td>     <td <?php if (date("D") == "Sun") echo('class="highlight"')?>>Sunday</td>   </tr> </table>[/code] it will add a class "highlight" to the <td> of the current day.
  10. if your DB is empty I would use Barand's example and set unique key in your DB. if you want to use my code then you should put it somewhere before you send the message or add anything to your DB. no point error checking afterwards is it  ;)
  11. it's been a long time since I've done any PHP coding so if it doesn't work... sorry. [code]$check = mysql_query("SELECT email FROM contacts"); $result = mysql_fetch_array($check); foreach ($result as $i) { if ($i == $_POST['requiredemail']) { exit("dupe"); } }[/code] what this *should* do is select all the "email" fields from "contacts" and store them in a new array. then the foreach() loops through them one by one and check them against $_POST['requiredemail']. it's a $i matches $_POST['requiredemail'] it will exit(). you can tidy this up a bit so it could print an error message or something.
  12. [!--quoteo(post=349799:date=Feb 27 2006, 06:44 AM:name=shan_cool)--][div class=\'quotetop\']QUOTE(shan_cool @ Feb 27 2006, 06:44 AM) [snapback]349799[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi all, I want to get a value of a text box in a same form. how can i do it? can anybody help me? Thanks, Shan [/quote] $_POST['text box name here'];
  13. I have a page with session_start() when I view this page in IE6 all the links end with ?PHPSESSID=<session id here> when I refresh the page they all dissapear It's only IE doing it. does anyone know of a fix?
  14. You have to tell dreamweaver the type of file it is. go to new then you should see a window with things like templates etc. choose PHP and then start working with it. That is what happens with DW8 anyway. It's kinda silly really.
×
×
  • 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.