SunQuest
           Barter Zone
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsGeneralBarter Zone

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old December 17th, 2005, 12:34 AM
icandothat's Avatar
icandothat icandothat is offline
Moderator
Click here for more information.
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,548 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 2 h 20 m 4 sec
Reputation Power: 3
Will work for beer money

I just finished a long term PHP coding gig and I'm looking for work. Share the love.

Reply With Quote
  #2  
Old December 18th, 2005, 09:20 AM
ababab ababab is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 ababab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Will work for beer money

Well I can't pay much... but if you can add pagation to this search I'll pay you $25.


[div id="search" style="position:absolute; width:660px; height:115px; z-index:1; left: 29px; top: 244px;"]
[highlight=php]

$rs=mysql_connect ("localhost", "x", "x") or die ('I cannot connect to the database because: ' . mysql_error());

$rs=mysql_select_db ("x");

$sql = "SELECT * FROM `jobs` WHERE 1 ";

if (!empty($_POST['keyword'])){
$keyword = $_POST['keyword'];
$sql .= " AND keyword LIKE '%$keyword%' ";
}


if (!empty($_POST['city']) ){
$city = $_POST['city'];
$sql .= " AND city='$city' ";
}

if (!empty($_POST['state'] ) ){
$state = $_POST['state'];
$sql .= " AND state='$state' ";
}

if (!empty($_POST['catagory'])){
$catagory = $_POST['catagory'];
$sql .= " AND job='$catagory' ";
}

if (mysql_errno != 0){
echo "Error in query. Error is: " .mysql_error();
die();
}
$rs = @mysql_query($sql);

if(mysql_num_rows($rs) == 0){
echo("No Data match!");
}

$bgcolor = "#E0E0E0"; // light gray
while ($row = mysql_fetch_array( $rs ) )
{
if ($bgcolor == "#E0E0E0"){
$bgcolor = "#ffffcc";
}else{
$bgcolor = "#E0E0E0";
}

?>
<div id="results" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="<?php echo $bgcolor; ?>">
<td width="30%" align="center"><?php echo $row['keyword']; ?></td>
<td width="30%" align="center"><?php echo $row['city']; ?></td>
<td width="10%" align="center"><?php echo $row['state']; ?></td>
<td width="30%" align="center"><?php echo $row['job']; ?></td>
</tr>
</table></div><?php } ?></div>

Reply With Quote
  #3  
Old December 18th, 2005, 11:32 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Will work for beer money

lol, is that open to all?

php Code:
Original - php Code
  1.  
  2.  
  3. $displaynum = 5; // this is results per page
  4. $startpoint = $_GET['startpoint'];
  5. if ($startpoint == "") {
  6. $startpoint = 0;
  7. }
  8.  
  9. //********************************************** paginate 
  10. // e = entries, s = startpoint d = displaynum u = url data
  11. function paginate ($e, $s, $d, $u) {
  12.     $numpages = floor($e/$d);
  13.     if ($e % $d > 0){
  14.         $numpages += 1;
  15.     }
  16.     $page = $s/$d + 1;
  17.     $nextpage = $page + 1;
  18.     $previouspage = $page - 1;
  19.    
  20.     echo "This is page $page of $numpages. There are $e total listings.  <br>";
  21.     if ($previouspage > 0){
  22.         $val = ($previouspage - 1) * $d;
  23.         echo "<a href='?startpoint=$val$u'>previous</a>|";
  24.     }
  25.     for ($cnt = 1; $cnt <= $numpages ; $cnt ++){
  26.         $val = ($cnt - 1) * $d;
  27.         echo "<a href='?startpoint=$val$u'>$cnt</a>";
  28.         if ($numpages > 1 && $cnt < $numpages) {
  29.             echo "|";
  30.         }
  31.     }
  32.     if ($nextpage <= $numpages){
  33.         $val = ($nextpage - 1) * $d;
  34.         echo "|<a href='?startpoint=$val$u'>next</a>";
  35.     }
  36. }
  37.  
  38. echo "<div id='search' style='position:absolute; width:660px; height:115px; z-index:1; left: 29px; top: 244px;'>";
  39.  
  40.  
  41.  
  42. $connect=mysql_connect ("localhost", "x", "x") or die ('I cannot connect to the database because: ' . mysql_error());
  43.  
  44. $db=mysql_select_db ("x");
  45.  
  46. $sql = "SELECT * FROM `jobs` WHERE 1 ";
  47.  
  48. if (!empty($_REQUEST['keyword'])){
  49. $keyword = $_REQUEST['keyword'];
  50. $url .= "&keyword=".$keyword;
  51. $sql .= " AND keyword LIKE '%$keyword%' ";
  52. }
  53.  
  54. if (!empty($_REQUEST['city']) ){
  55. $city = $_REQUEST['city'];
  56. $url .= "&city=".$city;
  57. $sql .= " AND city='$city' ";
  58. }
  59.  
  60. if (!empty($_REQUEST['state'] ) ){
  61. $state = $_REQUEST['state'];
  62. $url .= "&state=".$state;
  63. $sql .= " AND state='$state' ";
  64. }
  65.  
  66. if (!empty($_REQUEST['catagory'])){
  67. $catagory = $_REQUEST['catagory'];
  68. $url .= "&catagory=".$catagory;
  69. $sql .= " AND job='$catagory' ";
  70. }
  71.  
  72. $sql .= "LIMIT $startpoint, $display_num";
  73.  
  74.  
  75. $rs = @mysql_query($sql);
  76. $entries = mysql_num_rows($rs);
  77. if($entries == 0){
  78. echo("No Data match!");
  79. } else {
  80.    echo "
  81.      <div id='results' >
  82.      <table width='100%' border='0' cellspacing='0' cellpadding='0'>
  83.    ";
  84.    while ($row = mysql_fetch_array($rs)){
  85.       $bgcolor = ($bgcolor=="#ffffcc")?"#E0E0E0":"#ffffcc";
  86.       echo "
  87.         <tr bgcolor='$bgcolor'>
  88.            <td width='30%' align='center'>".$row['keyword']."</td>
  89.            <td width='30%' align='center'>".$row['city']."</td>
  90.            <td width='10%' align='center'>".$row['state']."</td>
  91.            <td width='30%' align='center'>".$row['job']."</td>
  92.         </tr>
  93.       ";
  94.    } // close while
  95.    echo "<tr><td colspan='4'>";
  96.        paginate($entries, $startpoint, $diplaynum, $url);
  97.    echo "</td></tr>";
  98.    echo "</table> </div>";
  99. } // close else
  100. exho "</div>";


Reply With Quote
  #4  
Old December 18th, 2005, 12:05 PM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'PHP Coding' to 'Barter Zone' by tkarkkainen.

Reason:

Reply With Quote
  #5  
Old December 18th, 2005, 09:38 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,720 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 20 m 53 sec
Reputation Power: 6
RE: Will work for beer money

MySQL is looking for web developers - worldwide.

http://www.mysql.com/company/jobs/webdeveloper.html

Always good to know what is out there. *sigh* I'd apply but all my stuff is intranet so no URLS

Reply With Quote
  #6  
Old December 20th, 2005, 12:46 AM
ababab ababab is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 ababab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Will work for beer money

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/x/public_html/x/searchwithpaging.php on line 75

I am getting this message.

What should i do?

Reply With Quote
  #7  
Old December 20th, 2005, 01:10 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Will work for beer money

I can't see your code, hopefully you changed the code to match your table etc.

first you should get rid of the @ sign on your query it suppresses errors.

echo your query when it's complete so you can see if it has the proper query you're expecting.

you may be getting 0 results, or else you may be having trouble with mysql_num_rows() I have had this kind of problem in the past. It's not always clear to me why this function fails at certain times.

Reply With Quote
  #8  
Old December 20th, 2005, 01:38 AM
ababab ababab is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 ababab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Will work for beer money

the query is fine... It is running and working well on another page. The mysql_num_rows()works as well on other searches...so.. I will try and figure it out...if I have anymore questions I'll send them.

I will send the money either tonight or tomorrow..no problem

I have to become a member of pay pal still.

Thanks for your help

Reply With Quote
  #9  
Old December 20th, 2005, 03:04 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Will work for beer money

if you want to test the pagination code you can switch to adding a second query.

use the first query

"SELECT count(id) AS entries FROM table WHERE blah blah blah ";

to get the same results as mysql_num_rows() and you'll see that the pagination works.


Reply With Quote
  #10  
Old December 21st, 2005, 03:57 AM
ababab ababab is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 ababab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Will work for beer money

the code isnt working... I have been working on it for a while. have any more suggestions?

Reply With Quote