Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql in php help for database

Status
Not open for further replies.

AbbasAkhtar

Programmer
Dec 16, 2002
25
GB
OK, I've finally managed to figure out and to create a blank database in mysql called mydb and create a table called details which is like this

field: type: null:
name varchar(20) yes
age char(2) yes


what i want to do in php using apache server is how to do this:

receive a count of all the listed table data for example like this:

if i have this information stored in my table in mydb,

abbas akhtar, 17
john smith, 27

then the count would be 2, because their are only 2 bits of information,


i also want to be able to read in and print on the browser something like this:

all names in the field name, or age.

edit names, or age,

delete a whole name and age,

i want to be able to use a button for this, but i am not sure on how to execute commands to the mysql server,

i no if i use this

<?php
mysql_query(&quot;SELECT * FROM details&quot;);
?>

lists everything in the table called details (i no, i have to access the db first, yes i no this).

how could i execute for example the above command, would it be like this

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot; onclick &quot;<?php enter_code_here ?>&quot;)

or what, i also prefer to add all name ages in drop down combo boxes or something, but how the hell can i use html to program it,

im new to php, apache and mysql, and i have done a lot of searching, JUST to get it all installed on my windows box (not unix yet), and got it up running, and it took me a week to figure out how to create a database and create a table for that database and understand multiple tables can be created for that database.

anyway i think im doing ok, but i do need some help, so if anyone is like me and has some more experience, your help would be greatly appreciated.

thanks,

abbas akhtar.
 
If I understand your correctly, you want to select all people from your table and list them, with an option of deleting, and editing it. If you'd want a compact solution, I'd use a [tt]<table>[/tt] where each row looks something like
[tt]<tr>
<td>
<input type=&quot;checkbox&quot; name=&quot;delete[]&quot; value=&quot;$id&quot; />
</td>
<td>
<input type=&quot;text&quot; name=&quot;names[$id]&quot; value=&quot;$name&quot; />
</td>
<td>
<input type=&quot;text&quot; name=&quot;ages[$id]&quot; value=&quot;$age&quot; />
</td>
</tr>[/tt]
This would, however, post way more information than needed.
To get the count of records that you selected, you can use the function [tt]mysql_num_rows($resultHandle);[/tt]. You would also have to write a form processor, which would process your forms, which means that it can not be done with [tt]onclick[/tt], since that runs on the client side.

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top