|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Error
Nothing to say but I bet all of you see what's wrong out there.
Looking forward to Part 3 now. |
|
#2
|
|||
|
|||
|
HTML errors in the article
Unfortunately, the article is full of HTML errors like these:
<br> <html> <br> <br> This may only be visible in Netscape(?). |
|
#3
|
|||
|
|||
|
Re: HTML errors in the article
It's okay with MSIE. I just checked it out.
<br> Maybe, DevShed's editors are using IE. <br> <br> I wish this comments would notify the editor via email! < => < <br> <br> However, this article is great enough to stand the HTML error. <br> <br> Jaewoong |
|
#4
|
|||
|
|||
|
Good tutorial
Even though this is easy to pick up, I'm glad to see this kind of tutorial on php. I've been looking for something like this. I wonder how deep the php 101 is going to go.
|
|
#5
|
|||
|
|||
|
Php 101
Thanks for an excellent article on PHP!
It is simple yet powerful. |
|
#6
|
|||
|
|||
|
php101
good, but could have been longer
|
|
#7
|
|||
|
|||
|
Good beginnings
I'm sending this article to friends who are just starting to use PHP. I've been using it for a few months, and had never thought of using the <tt>$submit</tt> var.
<br> <br> However, I was a bit disappointed by the explanation of the <tt>===</tt> symbol. Although I understand what it does by reading the text, I didn't really see how it was applicable in the example. <br> <br> Looking forward to part 3! |
|
#8
|
|||
|
|||
|
If "whatever" = "nothing"?
I have a problem, I am setting up a simple job opportunity section for a radio station. I am using a mySQL database. I have no problem getting the searches to work and field to display. My problem is that when there are no jobs to display, I want to display a default "check back soon" message. I have tried everything I can think of, but still cannot get it to display the message if there are no jobs. I am pasting some of the code below and will highlight with ***** the place I am working on. Thanks to any brains that can help me.
<? # setup SQL statement $SQL = " SELECT * FROM Opportunities WHERE Paid = 'yes'"; # execute SQL statement $retid = mysql_db_query($db, $SQL, $cid); # Get num of rows $numrows = mysql_numrows($retid); # check for errors if (!$retid) { echo( mysql_error()); } else { # display results while ($row = mysql_fetch_array($retid)) { $title = $row["Title"]; $pay = $row["Pay_Rate"]; $desc = $row["Description"]; $skills = $row["Skills"]; *********************************** (what's below doesn't work, please help! if ($title != "") { echo ("<font face=arial size=2><b>DEFAULT MESSAGE HERE!</b></font>"); } *********************************** if ($title > "") { echo ("<table cellpadding=0 cellspacing=0 border=0> <tr><td valign=top align=right> <font face=arial size=2><b>Title: </b></font> </td><td valign=top> <font face=arial size=3><b>$title</b></font> </td></tr> \n"); } if ($pay > "") { echo ("<tr><td valign=top align=right> <font face=arial size=2><b>Pay: </b></font> </td><td valign=top> <font face=arial size=2>$pay</font> </td></tr> \n"); } etc. etc.. Thanks, Mike |
|
#9
|
|||
|
|||
|
Re: If
This may seem too simple, but I don't know if I know what you're asking:
if (!empty($title)) { print "Title: $title <BR>\n"; } if (!empty($pay)) { print "Pay: $pay <BR>\n"); } |
|
#10
|
|||
|
|||
|
Re: If
Thanks, but that isn't it. I have got it to work if it is not empty, the problem comes when there are no jobs. I can do what you did with *** if ($title > "") { echo... *** and it works perfectly, however if there are no jobs in the database, I can't make it display a default "Sorry nothing available" type message. I thought of ***if ($title = "") { echo... *** , (meaning equal to nothing) but it didn't work. I have also tried a multitude of other "not equal to" type language, but it still will not display the message.
<br> <br> I am wondering if there is some syntax that I either don't have or do have previously in the script that could be nullifying this function somehow. <br> <br> Mike |
|
#11
|
|||
|
|||
|
Re: If
Ok, ok, ok....
you said: if ($title = "") that would always be true! you should say: if ($title == "") You need to display more of your program. Go back a couple steps. You are getting the data from a mySQL database. something like this: $sql = "SELECT * FROM tablename"; $result = mysql_query($sql); if ($result && $num = mysql_num_rows($result)) { // display your results } else { // display your error message of none to see } |
|
#12
|
|||
|
|||
|
Re: If
I may have said that a little too quick in the last message.
Let me clarify. Use the function mysql_num_rows() to see if there are results or not. Here is another way to accomplish the same thing: $sql = "SELECT * FROM tablename"; $result = mysql_query($sql); if ($result) { if (mysql_num_rows($result) > 0) { // display your results } else { // display your error message of none to see } } else { // could not query the database for some reason or another. } |
|
#13
|
|||
|
|||
|
Re: If
Yes, that worked. I am extremely grateful for your help. I had tried about everything, and of course the answer was actually quite simple to implement as usual.
Mike |
|
#14
|
|||
|
|||
|
This is great stuff!
I have read several php books and felt that I was still missing a few basics. This is filling in those gaps.
Thanks!!!! Mel |
|
#15
|
|||
|
|||
|
Re: HTML errors in the article
Someone fixed the HTML errors. Thanks for that.
|
![]() |
| Viewing: Dev Shed Forums > Other > Development Articles > PHP 101 (Part 2) - Shakespeare's Rose |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|