•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,582 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 667 | Replies: 4
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Okay,
here's the deal. I am designing a "Craigslist" type deal using php/MySql.
I have everything down pat, EXCEPT I cannot figure out how to enter a simple search field (in HTML) where people can browse by city.
I have a little, no, very little experience with PhP. So, when I add the code, please know that everything I have is in BETA form, and is far from validation standards. So far, it all woks, except, I cannot figure out how to link a simple page that allows you to browse by cit.
Okay, here is the page that I am trying to get to:
I am just looking for a simple, one box form that will let you (again), put in a city, and browse people who submitted an ad, depending on the city their ad was posted with. Also, I was looking for a way to change this "flag" system that I have concocted, because it is kinda lame. I would rather try to find a way to have a simple one-button way. ACtually, If there was a way to propogate the AdNumber $variable in a hidden HTML text feild , I would do that. I'm sure there is, but, again, I am less than a novice PhP writer. My main concern is the search. I just want to get it right, and done.
ANY HELP is greatly appriciated -(besides being told to go back to school)-
Thank You Ω
here's the deal. I am designing a "Craigslist" type deal using php/MySql.
I have everything down pat, EXCEPT I cannot figure out how to enter a simple search field (in HTML) where people can browse by city.
I have a little, no, very little experience with PhP. So, when I add the code, please know that everything I have is in BETA form, and is far from validation standards. So far, it all woks, except, I cannot figure out how to link a simple page that allows you to browse by cit.
Okay, here is the page that I am trying to get to:
<?php
require("header.php");
echo"<font size='5'>";
echo"General Header";
echo"</font>";
// Make a MySQL Connection
mysql_connect("fakeserver", "model_login", "fakepassword") or die(mysql_error());
mysql_select_db("model_login") or die(mysql_error());
// Get all the data from the "myfiles" table
$result = mysql_query("SELECT * FROM myfiles ORDER BY 1 DESC")
or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo"<center>";
echo"<table width='800' height='500' bgcolor='CCCCCC' cellpadding='2' cellspacing='10'>";
echo"<tr><td>";
echo"<b>";
echo $row['username'];
echo"<br>";
echo"From: ";
echo $row['city'];
echo"</td></tr>";
echo"<br>";
echo"<tr align='center' bgcolor='CCCCFF' border='10'><td align='center'>";
echo"<font size='2'>";
echo $row['description'];
echo"</font>";
echo"</td>";
echo"<br>";
echo"<td align='center'>";
echo "<img width='330' height='300' src=\"junk/".$row['file']."\" >";
echo"<br>";
echo"<table width='250'>";
echo"Ad Number-><font size='4' color='red'>";
echo $row['RecordID'];
echo"<br>";
echo"<font size='2' color='000000'><B>";
echo"To flag this ad, enter the AdNumber (in red), and a description as to why, then<br> hit the flag button";
echo"</table>";
echo"</td></tr></table>";
echo"<br>";
echo"<br>";
echo"<FORM METHOD='POST' ACTION='flag.php'>AdNumber<INPUT TYPE='text' NAME='ID' SIZE=3>
Brief FLAG reason:<INPUT TYPE='text' Name='reason' Size='30'><INPUT TYPE='SUBMIT' Name='Flag' value='FLAG'></form>";
echo"<br>";
echo"_________________________________________________________________________________________";
}
?>I am just looking for a simple, one box form that will let you (again), put in a city, and browse people who submitted an ad, depending on the city their ad was posted with. Also, I was looking for a way to change this "flag" system that I have concocted, because it is kinda lame. I would rather try to find a way to have a simple one-button way. ACtually, If there was a way to propogate the AdNumber $variable in a hidden HTML text feild , I would do that. I'm sure there is, but, again, I am less than a novice PhP writer. My main concern is the search. I just want to get it right, and done.
ANY HELP is greatly appriciated -(besides being told to go back to school)-
Thank You Ω
Hi. Did you think in use some simple PHP Ajax script?
There i upload to you an example.
www.mazur.com.ar/combos.rar
You have to create the database to test it, and change the second 'select' with a table.
ch.-
There i upload to you an example.
www.mazur.com.ar/combos.rar
You have to create the database to test it, and change the second 'select' with a table.
ch.-
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Hi. Did you think in use some simple PHP Ajax script?
There i upload to you an example.
www.mazur.com.ar/combos.rar
You have to create the database to test it, and change the second 'select' with a table.
ch.-
I'll check that out, and thanks for replying. Sadly, I have NO AJAX experience. My field in Web Design is more the DESIGN, than the implication.
But I am realtively smart, so I will check it out and see if I can make sense of any of it.
•
•
Join Date: Dec 2007
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 2
Well, your SQL directive and what you want seems to be different.
try for instance:
Select CONCAT(name,city).
that is not even a problem like the disaster waiting to happen in your table:
you sure you want to create tables continously in your page?
please go through what you want, i feel you are going to get a different result here.
Cheers!
try for instance:
Select CONCAT(name,city).
that is not even a problem like the disaster waiting to happen in your table:
you sure you want to create tables continously in your page?
please go through what you want, i feel you are going to get a different result here.
Cheers!
•
•
Join Date: Aug 2008
Posts: 375
Reputation:
Rep Power: 1
Solved Threads: 34
Howdy,
Using a text input box for searching for city will likely be problematic -- because of spelling errors, capitalization differences, same city/different state, sql injection concerns ... the list goes on.
I would use a form <select><option> type drop down menu and populate it from the cities table in the database.
But in essence you will need to grab the form input value with PHP and use it in a sequel query.
But I really think this is a bad way to go, this doesn't take into account most of the things I mentioned above. Instead maybe use something like this ...
Then you mostly only have to worry about SQL injection and can still use the first example code above.
There's more to it that this, like filtering the city names to pass the validation test later, and similar details, but this is a general idea.
Hope it helps
Using a text input box for searching for city will likely be problematic -- because of spelling errors, capitalization differences, same city/different state, sql injection concerns ... the list goes on.
I would use a form <select><option> type drop down menu and populate it from the cities table in the database.
But in essence you will need to grab the form input value with PHP and use it in a sequel query.
<?php
if ( $city = $_POST['city'] ) {
if ( !preg_match( '/^[\s\w]+$/', $city) ) {
die( "Please only use numbers and letters in your search" );
}
$result = mysql_query( "SELECT * FROM `my_table` WHERE `city`='$city'" );
if ( mysql_num_rows( $result ) ) {
// do something with the results here ...
$obj= mysql_fetch_object( $result );
print $obj->field_name; // etc ...
}
}
?>
<html>
<head>
</head>
<body>
<form method="POST">
<input type="text" name="city" />
<input type="submit" />
</form>
</body>
</html><?php
print '<select name="city">';
$result = mysql_query( "SELECT * FROM `cities`" );
while ( $obj = mysql_fetch_object( $result ) ) {
print "<option value=\"$obj->city_id\">$obj->city_name</option>";
}
print '</select>';
?>There's more to it that this, like filtering the city names to pass the validation test later, and similar details, but this is a general idea.
Hope it helps
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
accounting software selection blog business software competition complete information core daniweb erp systems evaluation evaluations fedora gentoo legacy linux new folder new viruses news nhatquanglan php project project management security selection software selection software solutions spam svchost technology evaluation virus web
- How earn through online PHP project????? (PHP)
- I need a great web designer and proffesional PHP Coder ~ 10k project (Web Development Job Offers)
- Project (Java)
- PHP vs ASP... the big ShOwdOwN (IT Technologies and Trends)
- Multiple vulnerabilities in PHP 4/5 (PHP)
- php project (PHP)
Other Threads in the PHP Forum
- Previous Thread: HELP! - saving form data
- Next Thread: Sending an image to email via PHP form?


Linear Mode