Jump to content

Hopefully This is easy for you Pros


rtkiii

Recommended Posts

I'm new to PHP.  And I dont want to get crazy involved in the project, because it isn't my specialty.

 

I was asked to help out with website for a friend.  So i thought i'd come to you, because it's more in depth than my knowledge takes me...which isnt far at all.  Basically i created a DB with Mysql(Yahoo feature included with subscription)  and i need to be able to search it(display it) by certain fields(First Name, Last Name, State, Height...etc)

 

I found a couple tutorials where i could get a basic search and result function going with the data they gave me, but i can't figure out how to cut and paste my info in.  I thought i had the basic understanding of what was going on, but i dont.

 

Anyway anyone can help with this.  Just need a script to display a results page(where i only need to add in my DB name, hostname, table name and then i can input the feild names within the table) with a place to put in like 10 fields(if someone can do three, i can take it from there, i think) - and if you wanted to do a simple search(which i think i have already) - but i would need the "Name" field to pop up as a link(is that even possible?)

 

Everything i have found online is more advanced than this and i can't makje sense of it.  If i need to read a book please tell me...but i didn't want to put that much time into this small project because I have design things to do...

 

Any help would be very appreciated.

 

Thanks.

Link to comment
Share on other sites

I'm afraid were not here to write code for you. Either get crazy involved in the project and learn php, or hire someone to build it for you / find a free script you can customize.

 

thats what i figured i would get....thanks

Link to comment
Share on other sites

You could try posting your request within our freelance forum.

 

There really isnt any money to be made...so the person asking me to help can't pay...thats why i went this route.  I figured it was something quick for you guys...that it would take that long...but im sure im mistaken  =:)

Link to comment
Share on other sites

Okay I got the results/search to refernce my DB i created.  But on the Search Webpage it only sends back info if i search under the "name" field in the drop down menu.  If i put in anything or nothing it works fine...but the "ID" field and the "City/State" fields they don't do jack.

 

www.richardthomaskeel.com/search.html

 

search code

<body>

<form method="post" action="http://www.richardthomaskeel.com/results.php" target="_blank">

<div align="center">

<table border="0" cellpadding="0" cellspacing="0">

<tr>

<td bordercolor="#000000">

<p align="center">

<select name="metode" size="1">

<option value="id">ID</option>

<option value="name">Name</option>

<option value="City/State">City/State</option>

</select> <input type="text" name="search" size="25">  <br>

Search database: <input type="submit" value="Go!!" name="Go"></p>

</td>

</tr>

</table>

</div>

</form>

</body>

 

Result Code

<body>

<center>

<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">

<tr>

<td width="60"><b>id</b></td>

<td width="100"><b>name</b></td>

<td width="100"><b>City/State</b></td>

</tr>

<tr>

<td>

<? $hostname = "mysql";

$username = "******"; // The username you created for this database.

$password = "********"; // The password you created for the username.

$usertable = "Data"; // The name of the table you made.

$dbName = "test"; // This is the name of the database you made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");

@mysql_select_db( "$dbName") or die( "Unable to select database");

?>

<?

//error message (not found message)begins

$XX = "No Record Found, to search again please close this window";

//query details table begins

$query = mysql_query("SELECT * FROM Data WHERE $metode LIKE '%$search%' LIMIT 0, 50");

while ($row = @mysql_fetch_array($query))

{

$variable1=$row["id"];

$variable2=$row["name"];

$variable3=$row["City/State"];

//table layout for results

print ("<tr>");

print ("<td>$variable1</td>");

print ("<td>$variable2</td>");

print ("<td>$variable3</td>");

print ("<td>$variable4</td>");

print ("</tr>");

}

//below this is the function for no record!!

if (!$variable1)

{

print ("$XX");

}

//end

?>

</table>

</center>

</body>

</html>

 

 

You see anything im doing wrong?

 

thanks,

Rich

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.